Hi, I'm trying to build my first extension. I change all my code to lowercase, but still I get some errors and modx do not create me a table. I don't know where does it come from.
Error.log
[2012-11-15 10:16:54] (ERROR @ /index.php) Could not load class: news from mysql.news.
[2012-11-15 10:16:54] (ERROR @ /index.php) Could not load class: news from mysql.news.
[2012-11-15 10:17:26] (ERROR @ /index.php) Could not load class: news from mysql.news.
[2012-11-15 10:17:26] (ERROR @ /index.php) Could not load class: news from mysql.news.
[2012-11-15 10:17:52] (ERROR @ /index.php) Could not load class: news from mysql.news.
[2012-11-15 10:17:52] (ERROR @ /index.php) Could not load class: news from mysql.news.
Snippet.news.php
$canews = $modx->getService('newsbase','newsbase', $modx->getOption('canews.core_path',null,$modx->getOption('core_path').'model/canews/').'model/canews/',$scriptProperties);
//echo get_class($canews);
if(!($canews instanceof newsbase)) return 'zła instancja';
$tpl = $modx->getOption('tpl',$scriptProperties, 'rowTpl');
$sort = $modx->getOption('sort', $scriptProperties, 'id');
$dir = $modx->getOption('dir',$scriptProperties, 'ASC');
$output = '';
$m = $modx->getManager();
$created = $m->createObjectContainer('news');
return $created ? 'Table created.' : 'Table not created.';
mysql/news.class.php
require_once (dirname(dirname(__FILE__)) . '/news.class.php');
//require_once (strtr(realpath(dirname(dirname(__FILE__))), '\\', '/') . '/news.class.php');
class news_mysql extends news {
public function __construct(& $xpdo) {
parent :: __construct($xpdo);
}
}
Schema file
<?xml version="1.0" encoding="UTF-8"?>
<model package="canews" baseClass="xPDOObject" platform="mysql" defaultEngigne="MyISAM">
<object class="category" table="category" extends="xPDOSimpleObject">
<field key="id" dbtype="int" precision="11" phptype="integer" />
<field key="created_at" dbtype="datetime" phptype="datetime" />
<field key="menuindex" dbtype="int" precision="5" phptype="integer" />
<composite alias="translation_collection" class="category_i18n" local="id" foreign="category_id" cardinality="many" owner="local" />
<composite alias="news_collection" class="news" local="id" foreign="category_id" cardinality="many" owner="local" />
</object>
<object class="category_i18n" table="category_i18n" extends="xPDOSimpleObject">
<field key="id" dbtype="int" precision="11" phptype="integer" />
<field key="category_id" dbtype="int" precision="11" phptype="integer" null="false"/>
<field key="lang_name" dbtype="varchar" precision="5" phptype="string" null="false"/>
<field key="title" dbtype="varchar" precision="255" phptype="string" default=""/>
</object>
<object class="news" table="news" extends="xPDOSimpleObject">
<field key="id" dbtype="int" precision="11" phptype="integer" />
<field key="created_at" dbtype="datetime" phptype="datetime" />
<field key="published_at" dbtype="datetime" phptype="datetime" />
<field key="depublished_at" dbtype="datetime" phptype="datetime" />
<field key="published" dbtype="int" precision="2" phptype="integer" />
<field key="category_id" dbtype="int" precision="11" phptype="integer" null="false"/>
<composite alias="translation_collection" class="news_i18n" local="id" foreign="news_id" cardinality="many" owner="local" />
</object>
<object class="news_i18n" table="news_i18n" extends="xPDOSimpleObject">
<field key="id" dbtype="int" precision="11" phptype="integer" />
<field key="news_id" dbtype="int" precision="11" phptype="integer" null="false" />
<field key="lang_name" dbtype="varchar" precision="5" phptype="string" null="false"/>
<field key="title" dbtype="varchar" precision="255" phptype="string" default=""/>
<field key="content" dbtype="text" phptype="string" default=""/>
</object>
</model>
model class
<?php
class news extends xPDOSimpleObject {}
model base class
<?php
class newsbase{
function __construct(modX &$modx, array $config = array()) {
$this->modx =&$modx;
$basePath = $this->modx->getOption('canews.core_path', $config, $this->modx->getOption('core_path') . 'components/canews/');
$assetsUrl = $this->modx->getOption('canews.assets_url', $config, $this->modx->getOption('assets_url') . 'components/canews/');
$this->config = array_merge(array(
'basePath' => $basePath,
'corePath' => $basePath,
'modelPath' => $basePath . 'model/',
'processorsPath' => $basePath . 'processors/',
'templatesPath' => $basePath . 'templates/',
'chunksPath' => $basePath . 'elements/chunks/',
'jsUrl' => $assetsUrl . 'js/',
'cssUrl' => $assetsUrl . 'css/',
'assetsUrl' => $assetsUrl,
'connectorUrl' => $assetsUrl . 'connector.php',
), $config);
}
}
?>
Does anyone has an idea what am I doing wrong?