__construct() public method

You can use the $config array to pass some configuration values to the object: tableName String The name of the database table to use. Default: #__appName_viewNamePlural (Ruby on Rails convention) idFieldName String The table key field name. Default: appName_viewNameSingular_id (Ruby on Rails convention) knownFields Array The known fields in the table. Default: read from the table itself autoChecks Boolean Should I turn on automatic data validation checks? fieldsSkipChecks Array List of fields which should not participate in automatic data validation checks. aliasFields Array Associative array of "magic" field aliases. behavioursDispatcher EventDispatcher The model behaviours event dispatcher. behaviourObservers Array The model behaviour observers to attach to the behavioursDispatcher. behaviours Array A list of behaviour names to instantiate and attach to the behavioursDispatcher. fillable_fields Array Which fields should be auto-filled from the model state (by extent, the request)? guarded_fields Array Which fields should never be auto-filled from the model state (by extent, the request)? relations Array (hashed) The relations to autoload on model creation. contentType String The UCM content type, e.g. "com_foobar.items" Setting either fillable_fields or guarded_fields turns on automatic filling of fields in the constructor. If both are set only guarded_fields is taken into account. Fields are not filled automatically outside the constructor.
See also: Model::__construct()
public __construct ( Container $container, array $config = [] )
$container FOF30\Container\Container The configuration variables to this model
$config array Configuration values for this model
Example #1
0
File: Parts.php Project: Joal01/fof
 public function __construct(Container $container, array $config = array())
 {
     // I have to manually disable autoChecks, otherwise FOF will try to search for the form, raising
     // a fatal error
     $config['autoChecks'] = false;
     parent::__construct($container, $config);
 }
Example #2
0
 /**
  * Assigns callback functions to the class, the $methods array should be an associative one, where
  * the keys are the method names, while the values are the closure functions, e.g.
  *
  * array(
  *    'foobar' => function(){ return 'Foobar'; }
  * )
  *
  * @param           $container
  * @param array     $config
  * @param array     $methods
  */
 public function __construct(Container $container, array $config = array(), array $methods = array())
 {
     foreach ($methods as $method => $function) {
         $this->methods[$method] = $function;
     }
     parent::__construct($container, $config);
 }
Example #3
0
 /**
  * Public constructor. Overrides the parent constructor, making sure there are lft/rgt columns which make it
  * compatible with nested sets.
  *
  * @see \FOF30\Model\DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \RuntimeException When lft/rgt columns are not found
  */
 public function __construct(Container $container = null, array $config = array())
 {
     parent::__construct($container, $config);
     if (!$this->hasField('lft') || !$this->hasField('rgt')) {
         throw new TreeIncompatibleTable($this->tableName);
     }
 }
Example #4
0
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_environments';
     $config['idFieldName'] = 'id';
     parent::__construct($container, $config);
     $this->blacklistFilters(['title']);
     // Behaviours
     $this->addBehaviour('Filters');
 }
Example #5
0
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_dlidlabels';
     $config['idFieldName'] = 'ars_dlidlabel_id';
     parent::__construct($container, $config);
     // Behaviours
     $this->addBehaviour('Filters');
     $this->addBehaviour('Created');
     $this->addBehaviour('Modified');
 }
Example #6
0
 public function __construct(Container $container, array $config)
 {
     $defaultConfig = ['tableName' => '#__ak_profiles', 'idFieldName' => 'id'];
     if (!is_array($config) || empty($config)) {
         $config = [];
     }
     $config = array_merge($defaultConfig, $config);
     parent::__construct($container, $config);
     $this->addBehaviour('filters');
     $this->blacklistFilters(['configuration', 'filters']);
 }
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_updatestreams';
     $config['idFieldName'] = 'id';
     $config['aliasFields'] = ['enabled' => 'published', 'created_on' => 'created', 'modified_on' => 'modified', 'locked_on' => 'checked_out_time', 'locked_by' => 'checked_out'];
     parent::__construct($container, $config);
     // Relations
     $this->belongsTo('categoryObject', 'Categories', 'category', 'id');
     // Behaviours
     $this->addBehaviour('Filters');
     $this->addBehaviour('Created');
     $this->addBehaviour('Modified');
 }
Example #8
0
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_autoitemdesc';
     $config['idFieldName'] = 'id';
     $config['aliasFields'] = ['enabled' => 'published'];
     parent::__construct($container, $config);
     // Behaviours
     $this->addBehaviour('Filters');
     // Relations
     $this->belongsTo('categoryObject', 'Categories', 'category', 'id');
     // Eager loaded relations setup
     $this->with(['categoryObject']);
 }
Example #9
0
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_log';
     $config['idFieldName'] = 'id';
     parent::__construct($container, $config);
     // Disable automatic checks
     $this->autoChecks = false;
     // Relations
     $this->hasOne('item', 'Items', 'item_id', 'id');
     // Behaviours
     $this->addBehaviour('Filters');
     $this->addBehaviour('RelationFilters');
     $this->addBehaviour('Created');
     $this->addBehaviour('Modified');
     $this->with(['item']);
 }
Example #10
0
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_categories';
     $config['idFieldName'] = 'id';
     $config['aliasFields'] = ['slug' => 'alias', 'enabled' => 'published', 'created_on' => 'created', 'modified_on' => 'modified', 'locked_on' => 'checked_out_time', 'locked_by' => 'checked_out'];
     // Automatic checks should not take place on these fields:
     $config['fieldsSkipChecks'] = ['description', 'groups', 'vgroup_id', 'show_unauth_links', 'redirect_unauth', 'language', 'checked_out', 'checked_out_time', 'modified', 'modified_by', 'created', 'created_by'];
     parent::__construct($container, $config);
     // Relations
     $this->belongsTo('visualGroup', 'VisualGroups', 'vgroup_id', 'id');
     $this->hasMany('releases', 'Releases', 'id', 'category_id');
     $this->with(['visualGroup']);
     // Behaviours
     $this->addBehaviour('Filters');
     $this->addBehaviour('Created');
     $this->addBehaviour('Modified');
     // Some filters we will have to handle programmatically so we need to exclude them from the behaviour
     $this->blacklistFilters(['vgroup_id', 'language']);
 }
Example #11
0
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->belongsTo('contact', 'Contacts', 'contact_id', 'contactpro_contact_id');
 }
Example #12
0
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_items';
     $config['idFieldName'] = 'id';
     $config['aliasFields'] = ['slug' => 'alias', 'enabled' => 'published', 'created_on' => 'created', 'modified_on' => 'modified', 'locked_on' => 'checked_out_time', 'locked_by' => 'checked_out'];
     // Automatic checks should not take place on these fields:
     $config['fieldsSkipChecks'] = ['description', 'filename', 'url', 'updatestream', 'md5', 'sha1', 'filesize', 'groups', 'hits', 'created', 'created_by', 'modified', 'modified_by', 'checked_out', 'checked_out_time', 'ordering', 'show_unauth_links', 'redirect_unauth', 'language', 'environments'];
     parent::__construct($container, $config);
     // Relations
     $this->belongsTo('release', 'Releases', 'release_id', 'id');
     $this->hasOne('updateStreamObject', 'UpdateStreams', 'updatestream', 'id');
     $this->with(['release', 'updateStreamObject']);
     // Behaviours
     $this->addBehaviour('Filters');
     $this->addBehaviour('RelationFilters');
     $this->addBehaviour('Created');
     $this->addBehaviour('Modified');
     // Some filters we will have to handle programmatically so we need to exclude them from the behaviour
     $this->blacklistFilters(['language']);
     // Defaults
     $this->access = 1;
 }
Example #13
0
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->hasMany('requests', 'Requests', $this->getKeyName(), 'contact_id');
 }
Example #14
0
 /**
  * Public constructor. Overrides the parent constructor.
  *
  * @see DataModel::__construct()
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  *
  * @throws \FOF30\Model\DataModel\Exception\NoTableColumns
  */
 public function __construct(Container $container, array $config = array())
 {
     $config['tableName'] = '#__ars_releases';
     $config['idFieldName'] = 'id';
     $config['aliasFields'] = ['title' => 'version', 'slug' => 'alias', 'enabled' => 'published', 'created_on' => 'created', 'modified_on' => 'modified', 'locked_on' => 'checked_out_time', 'locked_by' => 'checked_out'];
     // Automatic checks should not take place on these fields:
     $config['fieldsSkipChecks'] = ['description', 'notes', 'groups', 'hits', 'created', 'created_by', 'modified', 'modified_by', 'checked_out', 'checked_out_time', 'ordering', 'show_unauth_links', 'redirect_unauth', 'language'];
     parent::__construct($container, $config);
     // Relations
     $this->belongsTo('category', 'Categories', 'category_id', 'id');
     $this->hasMany('items', 'Items', 'id', 'release_id');
     $this->with(['category']);
     // Behaviours
     $this->addBehaviour('Filters');
     $this->addBehaviour('RelationFilters');
     $this->addBehaviour('Created');
     $this->addBehaviour('Modified');
     // Some filters we will have to handle programmatically so we need to exclude them from the behaviour
     $this->blacklistFilters(['language', 'maturity']);
     // Defaults
     $this->access = 1;
     $this->maturity = 'alpha';
     $this->language = '*';
 }