Example #1
0
 /**
  * Method to instantiate a content type object.
  *
  * @param   mixed  $db    An optional argument to provide dependency injection for the database
  *                        adapter.  If the argument is a JDatbase adapter that object will become
  *                        the database adapter, otherwise the default adapter will be used.
  * @param   mixed  $user  An optional argument to provide dependency injection for the user. If the
  *                        argument is a JUser instance that object will become the user, otherwise the
  *                        default user will be used.
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 public function __construct(JDatabase $db = null, JUser $user = null)
 {
     parent::__construct($db);
     // If a user object is given, use it.
     if ($user instanceof JUser) {
         $this->user = $user;
     } else {
         $this->user = JFactory::getUser();
     }
     // Get an authoriser from the factory.
     $this->authoriser = JAuthorisationFactory::getInstance()->getAuthoriser();
 }
Example #2
0
 /**
  * Sets an instance of a factory object to return on subsequent calls of getInstance.
  *
  * @param   JAuthorisationFactory  $instance  A JAuthorisationFactory object.
  *
  * @return  void
  *
  * @since   12.1
  */
 public static function setInstance(JAuthorisationFactory $instance = null)
 {
     self::$_instance = $instance;
 }
Example #3
0
 /**
  * Method to instantiate the object.
  *
  * @param   string  $prefix   The custom prefix.
  * @param   object  $type     The JContentType object for the content object.
  * @param   mixed   $factory  An optional argument to provide dependency injection for the content
  *                            factory.  If the argument is a JContentFactory that object will become
  *                            the content factory, otherwise the default factory will be used.
  * @param   mixed   $db       An optional argument to provide dependency injection for the database
  *                            adapter.  If the argument is a JDatbase adapter that object will become
  *                            the database adapter, otherwise the default adapter will be used.
  * @param   mixed   $app      An optional argument to provide dependency injection for the application.
  *                            If the argument is a JApplicationWeb instance that object will become the application,
  *                            otherwise the default application will be used.
  * @param   mixed   $user     An optional argument to provide dependency injection for the user. If the
  *                            argument is a JUser instance that object will become the user, otherwise the
  *                            default user will be used.
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 public function __construct($prefix, $type, JContentFactory $factory = null, JDatabase $db = null, JApplicationWeb $app = null, JUser $user = null)
 {
     // Check if the type table is defined.
     if (!empty($type->table)) {
         // Add the type table and key.
         $this->tables['secondary'] = $type->table;
         $this->keys['secondary'] = array('primary' => 'content_id');
     }
     parent::__construct($db);
     // Set the content properties.
     $this->type = $type;
     $this->prefix = $prefix;
     // If an application object is given, use it.
     if ($app instanceof JApplicationWeb) {
         $this->app = $app;
     } else {
         $this->app = JFactory::getApplication();
     }
     // If a user object is given, use it.
     if ($user instanceof JUser) {
         $this->user = $user;
     } else {
         $this->user = JFactory::getUser();
     }
     // If a factory object is given, use it.
     if ($factory instanceof JContentFactory) {
         $this->factory = $factory;
     } else {
         $this->factory = JContentFactory::getInstance($this->prefix, $this->db, $this->app, $this->user);
     }
     // Get an authoriser from the factory.
     $this->authoriser = JAuthorisationFactory::getInstance()->getAuthoriser();
     // Set the cache group.
     $this->cacheGroup = $this->type->alias;
     // Register the dump properties.
     $this->dump[] = 'route';
     $this->dump[] = 'config';
 }