本文整理汇总了PHP中KService::getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP KService::getIdentifier方法的具体用法?PHP KService::getIdentifier怎么用?PHP KService::getIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KService
的用法示例。
在下文中一共展示了KService::getIdentifier方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setConfig
/**
* Configurator
*
* @param KConfig $config Property Configuration
*
* @return void
*/
public function setConfig(KConfig $config)
{
$identifier = $config->description->getRepository()->getIdentifier();
if ($config->parent) {
$this->_parent = KService::getIdentifier($config->parent);
//adopt the child application
if (!$this->_parent->application) {
$this->_parent->application = $identifier->application;
}
}
parent::setConfig($config);
if ($config->child) {
if (strpos($config->child, '.') === false) {
$identifier = clone $this->_parent;
$identifier->name = $config->child;
$config->child = $identifier;
}
$this->_child = KService::getIdentifier($config->child);
//adopt the parent application
if (!$this->_child->application) {
$this->_child->application = $identifier->application;
}
}
$this->_parent_key = $config->parent_key;
if (is_array($config->query)) {
$config->query = new KConfig($config->query);
}
$this->_query_filters = $config->query;
}
示例2: getIdentifier
/**
* Gets the service identifier.
*
* @return KServiceIdentifier
* @see KObjectServiceable
*/
public final function getIdentifier($identifier = null)
{
if (isset($identifier)) {
$result = $this->__service_container->getIdentifier($identifier);
} else {
$result = $this->__service_identifier;
}
return $result;
}
示例3: getIdentifier
/**
* Gets the service identifier.
*
* @throws KObjectException if the service container has not been defined.
* @return KServiceIdentifier
* @see KObjectServiceable
*/
public final function getIdentifier($identifier = null)
{
if (isset($identifier)) {
if (!isset($this->__service_container)) {
throw new KObjectException("Failed to call " . get_class($this) . "::getIdentifier(). No service_container object defined.");
}
$result = $this->__service_container->getIdentifier($identifier);
} else {
$result = $this->__service_identifier;
}
return $result;
}
示例4: setConfig
/**
* Configurator
*
* @param KConfig $config Property Configuration
*
* @return void
*/
public function setConfig(KConfig $config)
{
$identifier = $config->description->getRepository()->getIdentifier();
$config->child = $config->through;
parent::setConfig($config);
$this->_target = KService::getIdentifier($config->target);
if (!$this->_target->application) {
$this->_target->application = $identifier->application;
}
$this->_target_child_key = $config->target_child_key;
$this->_target_parent_key = $config->target_parent_key;
//set the junction alias (the connecting table alias)
$this->_junction_alias = $config->as;
}
示例5: addAuthorizer
/**
* Adds an authorizer.
*
* @param LibBaseDomainAuthorizerAbstract $authorizer The authorizer object
*/
public function addAuthorizer($authorizer)
{
if (!$authorizer instanceof LibBaseDomainAuthorizerAbstract) {
if (is_string($authorizer) && strpos($authorizer, '.') === false) {
//create identifier
$identifier = clone $this->_repository->getIdentifier();
$identifier->path = array('domain', 'authorizer');
$identifier->name = $authorizer;
register_default(array('identifier' => $identifier, 'prefix' => $this->_repository->getClone()));
} else {
$identifier = KService::getIdentifier($authorizer);
}
$authorizer = $identifier;
$authorizer = KService::get($authorizer);
}
array_unshift($this->_authorizers, $authorizer);
}
示例6: __construct
/**
* Constructor
*/
public function __construct($dispatcher, $config = array())
{
if (!$config instanceof KConfig) {
$config = new KConfig($config);
}
//Inject the identifier
$config->service_identifier = KService::getIdentifier('plg:koowa.' . $config['name']);
//Inject the service container
$config->service_container = KService::getInstance();
parent::__construct($config);
//Set the plugin params
if (is_string($config->params)) {
$config->params = $this->_parseParams($config->params);
}
$this->_params = $config->params;
//Setup lazy wiring for publishers we are subscribing too
foreach ($config->event_publishers as $publisher) {
KService::setConfig($publisher, array('event_subscribers' => array($this)));
}
if ($dispatcher instanceof KEventDispatcher) {
$dispatcher->addEventSubscriber($this);
}
}
示例7: getFilter
/**
* Get a filter by identifier
*
* @return KTemplateFilterInterface
*/
public function getFilter($filter)
{
//Create the complete identifier if a partial identifier was passed
if (is_string($filter) && strpos($filter, '.') === false) {
$identifier = clone $this->getIdentifier();
$identifier->path = array('template', 'filter');
$identifier->name = $filter;
} else {
$identifier = KService::getIdentifier($filter);
}
if (!isset($this->_filters[$identifier->name])) {
$filter = KService::get($identifier);
if (!$filter instanceof KTemplateFilterInterface) {
throw new KTemplateException("Template filter {$identifier} does not implement KTemplateFilterInterface");
}
} else {
$filter = $this->_filters[$identifier->name];
}
return $filter;
}
示例8: loadIdentifier
/**
* Load a class based on an identifier
*
* @param string|object The identifier or identifier object
* @return boolean Returns TRUE on success throws exception on failure
*/
public function loadIdentifier($identifier)
{
$result = false;
$identifier = KService::getIdentifier($identifier);
//Get the path
$path = $identifier->filepath;
if ($path !== false) {
$result = self::loadFile($path);
}
return $result;
}
示例9: __construct
/**
* Constructor
*/
function __construct($dispatcher, $config = array())
{
if (isset($config['params'])) {
if ($config['params'] instanceof JRegistry) {
$this->_params = $config['params'];
} else {
$this->_params = new JRegistry();
$this->_params->loadINI($config['params']);
}
}
if (isset($config['name'])) {
$this->_name = $config['name'];
}
if (isset($config['type'])) {
$this->_type = $config['type'];
}
//Inject the identifier
$config['service_identifier'] = KService::getIdentifier('plg:koowa.' . $this->_name);
//Inject the service container
$config['service_container'] = KService::getInstance();
//Inject the dispatcher
$config['dispatcher'] = $dispatcher;
parent::__construct(new KConfig($config));
}
示例10: renderComponent
static function renderComponent($name, $params = array())
{
global $mainframe, $option;
// Define component path
define('JPATH_COMPONENT', JPATH_BASE . DS . 'components' . DS . $name);
define('JPATH_COMPONENT_SITE', JPATH_SITE . DS . 'components' . DS . $name);
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . DS . 'components' . DS . $name);
if (!file_exists(JPATH_COMPONENT)) {
JError::raiseError(404, JText::_('Component Not Found'));
}
$file = substr($name, 4);
// get component path
if ($mainframe->isAdmin() && file_exists(JPATH_COMPONENT . DS . 'admin.' . $file . '.php')) {
$path = JPATH_COMPONENT . DS . 'admin.' . $file . '.php';
} else {
$path = JPATH_COMPONENT . DS . $file . '.php';
}
$identifier = KService::getIdentifier("com:{$file}.aliases");
$identifier->application = $mainframe->isAdmin() ? 'admin' : 'site';
$lang =& JFactory::getLanguage();
$lang->load($name);
KLoader::getInstance()->loadIdentifier($identifier);
//new way of doing it
if (!file_exists($path)) {
$identifier->name = 'dispatcher';
register_default(array('identifier' => $identifier, 'default' => 'ComBaseDispatcherDefault'));
$dispatcher = ComBaseDispatcher::getInstance();
KService::setAlias('component.dispatcher', $dispatcher->getIdentifier());
KService::set('component.dispatcher', $dispatcher);
return $dispatcher->dispatch();
} else {
$contents = self::_renderComponent($path);
// Build the component toolbar
jimport('joomla.application.helper');
if (($path = JApplicationHelper::getPath('toolbar')) && $mainframe->isAdmin()) {
// Get the task again, in case it has changed
$task = JRequest::getString('task');
// Make the toolbar
include_once $path;
}
return $contents;
}
}
示例11: _instantiateEntity
/**
* Instantiate a new entity based on the passed data This method is called from _create.
*
* @param string $identifier The identifier of the entity to instantiate
* @param array $data The raw data
*
* @return AnDomainEntityAbstract
*/
protected function _instantiateEntity($identifier, $data)
{
//since the identifier doesn't have an
//application set, it gets the application of the parent
//repository
$identifier = KService::getIdentifier($identifier);
$identifier->application = $this->getIdentifier()->application;
return clone AnDomain::getRepository($identifier)->getClone();
}
示例12: materialize
/**
* Materialize a many-to-one relationship for the entity and the data from
* the database.
*
* @param AnDomainEntityAbstract $instance The entity whose relationship it's materializing for
* @param array $data The row data
*
* @return AnDomainProxyEntity
*/
public function materialize(array $data, $instance)
{
if (empty($data)) {
return;
}
if (!$this->isMaterializable($data)) {
throw new AnDomainExceptionMapping($this->getName() . ' Mapping Failed');
}
$child_key = $this->_child_column->key();
//get parent value
$parent_value = $data[$child_key];
//get parent class identifier
//if relationsip is polymorphic then get the type from
//the data
if ($this->_polymorphic) {
$key = $this->_type_column->key();
$parent = isset($data[$key]) ? $data[$key] : null;
if ($parent) {
$parent = KService::getIdentifier($parent);
if (!$parent->application) {
$parent->application = $this->_child->application;
}
}
} else {
$parent = $this->_parent;
}
//if any of the parent and parent value is missing then
//nullify the relationship
if (empty($parent) || empty($parent_value)) {
return;
}
$config = array();
$config['relationship'] = $this;
$config['value'] = $parent_value;
$config['property'] = $this->_parent_key;
$config['service_identifier'] = AnDomain::getRepository($parent)->getDescription()->getEntityIdentifier();
return new AnDomainEntityProxy(new KConfig($config));
}
示例13: __construct
/**
* Constructor
*/
function __construct($dispatcher, $config = array())
{
if (isset($config['params'])) {
if ($config['params'] instanceof JRegistry) {
$this->_params = $config['params'];
} else {
$this->_params = new JRegistry();
if (version_compare(JVERSION, '1.6', '<')) {
$this->_params->loadINI($config['params']);
} else {
$this->_params->loadString($config['params'], 'INI');
}
}
}
if (isset($config['name'])) {
$this->_name = $config['name'];
}
if (isset($config['type'])) {
$this->_type = $config['type'];
}
//Inject the identifier
$config['service_identifier'] = KService::getIdentifier('plg:koowa.' . $this->_name);
//Inject the service container
$config['service_container'] = KService::getInstance();
//Inject the dispatcher
$config['dispatcher'] = KService::get('com://admin/default.event.dispatcher');
parent::__construct(new KConfig($config));
}
示例14: getEntityIdentifier
/**
* Entity Identifers must have application in their path. This method set the
* application of an identifier if the path is missing.
*
* @param string $identifier Entity Identifier
*
* @return KServiceIdentifier
*/
public static function getEntityIdentifier($identifier)
{
$identifier = KService::getIdentifier($identifier);
if (!$identifier->basepath) {
$adapters = KService::get('koowa:loader')->getAdapters();
$basepath = pick($adapters[$identifier->type]->getBasePath(), JPATH_BASE);
$applications = array_flip(KServiceIdentifier::getApplications());
if (isset($applications[$basepath])) {
$identifier->application = $applications[$basepath];
$identifier->basepath = $basepath;
}
}
return $identifier;
}