예제 #1
0
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   \JRegistry         $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  */
 public function __construct($config = array(), JoomlaContainer $container = null, \JRegistry $state = null, \JDatabaseDriver $db = null)
 {
     parent::__construct($config, $container, $state, $db);
     $this->eventAfterDelete = $this->eventAfterDelete ?: ArrayHelper::getValue($config, 'event_after_delete', 'onContentAfterDelete');
     $this->eventBeforeDelete = $this->eventBeforeDelete ?: ArrayHelper::getValue($config, 'event_before_delete', 'onContentBeforeDelete');
     $this->eventAfterSave = $this->eventAfterSave ?: ArrayHelper::getValue($config, 'event_after_save', 'onContentAfterSave');
     $this->eventBeforeSave = $this->eventAfterSave ?: ArrayHelper::getValue($config, 'event_before_save', 'onContentBeforeSave');
     $this->eventChangeState = $this->eventAfterSave ?: ArrayHelper::getValue($config, 'event_change_state', 'onContentChangeState');
     // @TODO: Check is needed or not.
     $this->textPrefix = $this->textPrefix ?: strtoupper(ArrayHelper::getValue($config, 'text_prefix', $this->option));
 }
예제 #2
0
 /**
  * Constructor
  *
  * @param   array              $config    An array of configuration options (name, state, dbo, table_path, ignore_request).
  * @param   JoomlaContainer    $container Service container.
  * @param   \JRegistry         $state     The model state.
  * @param   \JDatabaseDriver   $db        The database adapter.
  */
 public function __construct($config = array(), JoomlaContainer $container = null, \JRegistry $state = null, \JDatabaseDriver $db = null)
 {
     // These need before parent constructor.
     $this->orderCol = $this->orderCol ?: ArrayHelper::getValue($config, 'order_column', null);
     // This block should be remove after 3.0, use allowFields instead
     if (!$this->filterFields) {
         $this->filterFields = ArrayHelper::getValue($config, 'filter_fields', array());
         $this->filterFields[] = '*';
     }
     if (!$this->allowFields) {
         $this->allowFields = ArrayHelper::getValue($config, 'allow_fields', array());
         $this->allowFields[] = '*';
     }
     $this->prefix = $this->getPrefix($config);
     $this->option = 'com_' . $this->prefix;
     // Guess name for container
     $this->name = $this->name ?: ArrayHelper::getValue($config, 'name', $this->getName());
     $this->container = $container ?: $this->getContainer();
     $this->container->registerServiceProvider(new GridProvider($this->name, $this));
     $this->configureTables();
     parent::__construct($config, $container, $state, $db);
     // Guess the item view as the context.
     $this->viewList = $this->viewList ?: ArrayHelper::getValue($config, 'view_list', $this->getName());
     // Guess the list view as the plural of the item view.
     $this->viewItem = $this->viewItem ?: ArrayHelper::getValue($config, 'view_item');
     if (empty($this->viewItem)) {
         $inflector = Inflector::getInstance();
         $this->viewItem = $inflector->toSingular($this->viewList);
     }
 }