/** * Gets the User object corresponding to user id * * This is ONLY for the Application Container You need to use instead: * Application::MyUser() or Application::User( $idOrCondition ) only * @see \CBLib\Application\Application::MyUser() * * @param int|array|null $idOrConditions [optional] default: NULL: viewing user, int: User-id (0: guest), array: Criteria, e.g. array( 'username' => 'uniqueUsername' ) or array( 'email' => 'uniqueEmail' ) * @param CmsInterface $cms Cms object * @param Config $config Config * @return User User: if exists (registered user: singleton, guest: new instance), Guest user new instance if user not found */ public static function getInstanceForContainerOnly($idOrConditions = null, CmsInterface $cms, Config $config) { $cmsUser = null; if ($idOrConditions === null) { // Get viewing user: if (self::$myId === false) { $cmsUser = $cms->getCmsUser(null); self::$myId = (int) $cmsUser->get('id'); } $idOrConditions = self::$myId; } elseif (is_string($idOrConditions) && !is_numeric($idOrConditions)) { // Not a numeric $userIdOrAspect: Try getting the cmsUser by username: $cmsUser = $cms->getCmsUser($idOrConditions); if (!$cmsUser) { // No corresponding CMS user exists: Return a guest User instead: return new self(0, $cms->getCmsUser(0), $config); } $idOrConditions = (int) $cmsUser->get('id'); } $key = (string) (int) $idOrConditions; if (!isset(self::$usersCache[$key])) { if (!$cmsUser) { $cmsUser = $cms->getCmsUser($idOrConditions); } if ($cmsUser) { $self = new self($idOrConditions, $cmsUser, $config); if ((int) $idOrConditions === 0) { // No cache for guest/new user: return $self; } self::$usersCache[$key] = $self; } } return self::$usersCache[$key]; }
public static function createDatabaseDriver(CmsInterface $cms) { $cmsDatabaseDriver = $cms->getCmsDatabaseDriver(); if ($cmsDatabaseDriver) { $prefix = $cmsDatabaseDriver->getPrefix(); $cmsRelease = $cms->getCmsVersion(); return new CmsDatabaseDriver($cmsDatabaseDriver, $prefix, $cmsRelease); } else { $connection = null; //TODO LATER $prefix = $cms->getCfg('dbprefix'); return new MysqlDatabaseDriver($connection, $prefix); } }
/** * Constructor, sets the dependency-injection Container * * @param InputInterface $input Input object * @param OutputInterface $output Output object * @param CmsInterface $cms Cms object * @param ApplicationContainerInterface $di DI Container * @param array $options Main request options for dispatching * @param array $getParams [optional] Get params for form target of form * @param TableInterface|ParamsInterface $data The data to render */ public function __construct(InputInterface $input, OutputInterface $output, CmsInterface $cms, ApplicationContainerInterface $di, array $options, array $getParams = array(), $data = null) { $this->input = $input; $this->output = $output; $this->cms = $cms; $this->di = $di; $this->options = $options; $this->getParams = $getParams; $this->data = $data; $extensionName = $this->cms->getExtensionName(); $extensionPath = $this->cms->getFolderPath($this->cms->getClientId()); // Make sure it's shared: /** @see AutoLoaderXml */ $this->di->set('CBLib\\AhaWow\\AutoLoaderXml', null, true); /** @var AutoLoaderXml $autoLoaderXml::_construct() */ $autoLoaderXml = $this->di->get('CBLib\\AhaWow\\AutoLoaderXml'); $autoLoaderXml->registerMap($extensionName, $extensionPath . '/xmlcb/controllers/frontcontroller.xml'); }
/** * Constructor * * @param InputInterface $input Inputs * @param DatabaseDriverInterface $db Database * @param CmsInterface $cms Client id (0: front, 1: admin) */ public function __construct(InputInterface $input, DatabaseDriverInterface $db, CmsInterface $cms) { $this->input = $input; $this->db = $db; $this->clientId = $cms->getClientId(); }