当前位置: 首页>>代码示例>>PHP>>正文


PHP App::className方法代码示例

本文整理汇总了PHP中Cake\Core\App::className方法的典型用法代码示例。如果您正苦于以下问题:PHP App::className方法的具体用法?PHP App::className怎么用?PHP App::className使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Core\App的用法示例。


在下文中一共展示了App::className方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _resolveClassName

 /**
  * Resolve a cache engine classname.
  *
  * Part of the template method for Cake\Core\ObjectRegistry::load()
  *
  * @param string $class Partial classname to resolve.
  * @return string|false Either the correct classname or false.
  */
 protected function _resolveClassName($class)
 {
     if (is_object($class)) {
         return $class;
     }
     return App::className($class, 'Cache/Engine', 'Engine');
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:15,代码来源:CacheRegistry.php

示例2: __construct

 /**
  * Sets up the configuration for the model, and loads ACL models if they haven't been already
  *
  * @param Table $model Table instance being attached
  * @param array $config Configuration
  * @return void
  */
 public function __construct(Table $model, array $config = [])
 {
     $this->_table = $model;
     if (isset($config[0])) {
         $config['type'] = $config[0];
         unset($config[0]);
     }
     if (isset($config['type'])) {
         $config['type'] = strtolower($config['type']);
     }
     parent::__construct($model, $config);
     $types = $this->_typeMaps[$this->config()['type']];
     if (!is_array($types)) {
         $types = [$types];
     }
     foreach ($types as $type) {
         $alias = Inflector::pluralize($type);
         $className = App::className($alias . 'Table', 'Model/Table');
         if ($className == false) {
             $className = App::className('Acl.' . $alias . 'Table', 'Model/Table');
         }
         $config = [];
         if (!TableRegistry::exists($alias)) {
             $config = ['className' => $className];
         }
         $model->hasMany($type, ['targetTable' => TableRegistry::get($alias, $config)]);
     }
     if (!method_exists($model->entityClass(), 'parentNode')) {
         trigger_error(__d('cake_dev', 'Callback {0} not defined in {1}', ['parentNode()', $model->entityClass()]), E_USER_WARNING);
     }
 }
开发者ID:cakephp,项目名称:acl,代码行数:38,代码来源:AclBehavior.php

示例3: _resolveClassName

 /**
  * Resolve a driver classname.
  *
  * Part of the template method for Cake\Core\ObjectRegistry::load()
  *
  * @param string $class Partial classname to resolve.
  * @return string|false Either the correct classname or false.
  */
 protected function _resolveClassName($class)
 {
     if (is_object($class)) {
         return $class;
     }
     return App::className($class, 'Datasource');
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:15,代码来源:ConnectionRegistry.php

示例4: cell

 /**
  * Renders the given cell.
  *
  * Example:
  *
  * ```
  * // Taxonomy\View\Cell\TagCloudCell::smallList()
  * $cell = $this->cell('Taxonomy.TagCloud::smallList', ['limit' => 10]);
  *
  * // App\View\Cell\TagCloudCell::smallList()
  * $cell = $this->cell('TagCloud::smallList', ['limit' => 10]);
  * ```
  *
  * The `display` action will be used by default when no action is provided:
  *
  * ```
  * // Taxonomy\View\Cell\TagCloudCell::display()
  * $cell = $this->cell('Taxonomy.TagCloud');
  * ```
  *
  * Cells are not rendered until they are echoed.
  *
  * @param string $cell You must indicate cell name, and optionally a cell action. e.g.: `TagCloud::smallList`
  * will invoke `View\Cell\TagCloudCell::smallList()`, `display` action will be invoked by default when none is provided.
  * @param array $data Additional arguments for cell method. e.g.:
  *    `cell('TagCloud::smallList', ['a1' => 'v1', 'a2' => 'v2'])` maps to `View\Cell\TagCloud::smallList(v1, v2)`
  * @param array $options Options for Cell's constructor
  * @return \Cake\View\Cell The cell instance
  * @throws \Cake\View\Exception\MissingCellException If Cell class was not found.
  * @throws \BadMethodCallException If Cell class does not specified cell action.
  */
 public function cell($cell, array $data = [], array $options = [])
 {
     $parts = explode('::', $cell);
     if (count($parts) === 2) {
         list($pluginAndCell, $action) = [$parts[0], $parts[1]];
     } else {
         list($pluginAndCell, $action) = [$parts[0], 'display'];
     }
     list($plugin) = pluginSplit($pluginAndCell);
     $className = App::className($pluginAndCell, 'View/Cell', 'Cell');
     if (!$className) {
         throw new Exception\MissingCellException(['className' => $pluginAndCell . 'Cell']);
     }
     $cell = $this->_createCell($className, $action, $plugin, $options);
     if (!empty($data)) {
         $data = array_values($data);
     }
     try {
         $reflect = new ReflectionMethod($cell, $action);
         $reflect->invokeArgs($cell, $data);
         return $cell;
     } catch (ReflectionException $e) {
         throw new BadMethodCallException(sprintf('Class %s does not have a "%s" method.', $className, $action));
     }
 }
开发者ID:rederlo,项目名称:cakephp,代码行数:56,代码来源:CellTrait.php

示例5: gizmo

 /**
  * Renders the given gizmo.
  *
  * Example:
  *
  * {{{
  * // Taxonomy\View\Gizmo\TagCloudGizmo::smallList()
  * $gizmo = $this->gizmo('Taxonomy.TagCloud::smallList', ['limit' => 10]);
  *
  * // App\View\Gizmo\TagCloudGizmo::smallList()
  * $gizmo = $this->gizmo('TagCloud::smallList', ['limit' => 10]);
  * }}}
  *
  * The `display` action will be used by default when no action is provided:
  *
  * {{{
  * // Taxonomy\View\Gizmo\TagCloudGizmo::display()
  * $gizmo = $this->gizmo('Taxonomy.TagCloud');
  * }}}
  *
  * Gizmos are not rendered until they are echoed.
  *
  * @param string $gizmo You must indicate gizmo name, and optionally a gizmo action. e.g.: `TagCloud::smallList`
  * will invoke `View\Gizmo\TagCloudGizmo::smallList()`, `display` action will be invoked by default when none is provided.
  * @param array $data Additional arguments for gizmo method. e.g.:
  *    `gizmo('TagCloud::smallList', ['a1' => 'v1', 'a2' => 'v2'])` maps to `View\Gizmo\TagCloud::smallList(v1, v2)`
  * @param array $options Options for Gizmo's constructor
  * @return \Cake\View\Gizmo The gizmo instance
  * @throws \Cake\View\Exception\MissingGizmoException If Gizmo class was not found.
  * @throws \BadMethodCallException If Gizmo class does not specified gizmo action.
  */
 public function gizmo($gizmo, array $data = [], array $options = [])
 {
     $parts = explode('::', $gizmo);
     if (count($parts) === 2) {
         list($pluginAndGizmo, $action) = [$parts[0], $parts[1]];
     } else {
         list($pluginAndGizmo, $action) = [$parts[0], 'display'];
     }
     list($plugin, $gizmoName) = pluginSplit($pluginAndGizmo);
     $className = App::className($pluginAndGizmo, 'View/Gizmo', 'Gizmo');
     if (!$className) {
         throw new Exception\MissingGizmoException(array('className' => $pluginAndGizmo . 'Gizmo'));
     }
     $gizmo = $this->_createGizmo($className, $action, $plugin, $options);
     if (!empty($data)) {
         $data = array_values($data);
     }
     try {
         $reflect = new \ReflectionMethod($gizmo, $action);
         $reflect->invokeArgs($gizmo, $data);
         return $gizmo;
     } catch (\ReflectionException $e) {
         throw new \BadMethodCallException(sprintf('Class %s does not have a "%s" method.', $className, $action));
     }
 }
开发者ID:splicephp,项目名称:gizmo,代码行数:56,代码来源:GizmoTrait.php

示例6: get

 /**
  * Get/Create an instance from the registry.
  *
  * When getting an instance, if it does not already exist,
  * a new instance will be created using the provide alias, and options.
  *
  * @param string $alias The name of the alias to get.
  * @param array $options Configuration options for the type constructor.
  * @return \Cake\ElasticSearch\Type
  */
 public static function get($alias, array $options = [])
 {
     if (isset(static::$instances[$alias])) {
         if (!empty($options) && static::$options[$alias] !== $options) {
             throw new RuntimeException(sprintf('You cannot configure "%s", it already exists in the registry.', $alias));
         }
         return static::$instances[$alias];
     }
     static::$options[$alias] = $options;
     list(, $classAlias) = pluginSplit($alias);
     $options = $options + ['name' => Inflector::underscore($classAlias)];
     if (empty($options['className'])) {
         $options['className'] = Inflector::camelize($alias);
     }
     $className = App::className($options['className'], 'Model/Type', 'Type');
     if ($className) {
         $options['className'] = $className;
     } else {
         if (!isset($options['name']) && strpos($options['className'], '\\') === false) {
             list(, $name) = pluginSplit($options['className']);
             $options['name'] = Inflector::underscore($name);
         }
         $options['className'] = 'Cake\\ElasticSearch\\Type';
     }
     if (empty($options['connection'])) {
         $connectionName = $options['className']::defaultConnectionName();
         $options['connection'] = ConnectionManager::get($connectionName);
     }
     static::$instances[$alias] = new $options['className']($options);
     return static::$instances[$alias];
 }
开发者ID:jeffersongoncalves,项目名称:elastic-search,代码行数:41,代码来源:TypeRegistry.php

示例7: get

 /**
  * Create an instance of a given classname.
  *
  * The config is ignore on susequent requests for the same object
  * name. To reconfigure an existing object, remove() it and re-get().
  *
  * @param string $class The class to build.
  * @param array $config The constructor configs to pass to the object.
  * @return mixed
  */
 public static function get($class, array $config = null)
 {
     if (!isset(static::$_instances[$class])) {
         $className = App::className($class, 'Lib', '');
         static::$_instances[$class] = new $className($config);
     }
     return static::$_instances[$class];
 }
开发者ID:loadsys,项目名称:cakephp-libregistry,代码行数:18,代码来源:LibRegistry.php

示例8: _resolveClassName

 /**
  * Resolve a storage class name.
  *
  * @param string $class Partial class name to resolve.
  * @return string The resolved class name.
  * @throws \Cake\Core\Exception\Exception
  */
 protected function _resolveClassName($class)
 {
     $className = App::className($class, 'Model/Storage', 'Storage');
     if (!$className) {
         throw new Exception(sprintf('Storage class "%s" was not found.', $class));
     }
     return $className;
 }
开发者ID:laughingpain,项目名称:oauth-server,代码行数:15,代码来源:GetStorageTrait.php

示例9: getTransformer

 /**
  * Generates instance of the Transformer.
  *
  * The method works with the App::className() method.
  * This means that you can call app-related Transformers like `Books`.
  * Plugin-related Transformers can be called like `Plugin.Books`
  *
  * @param $className
  * @return TransformerAbstract
  * @throws MissingTransformerException
  */
 public function getTransformer($className)
 {
     $transformer = App::className(Inflector::classify($className), 'Transformer', 'Transformer');
     if ($transformer === false) {
         throw new MissingTransformerException(['transformer' => $className]);
     }
     return new $transformer();
 }
开发者ID:cakeplugins,项目名称:api,代码行数:19,代码来源:TransformerAwareTrait.php

示例10: _resolveClassName

 /**
  * Resolve a behavior classname.
  *
  * Part of the template method for Cake\Core\ObjectRegistry::load()
  *
  * @param string $class Partial classname to resolve.
  * @return string|false Either the correct classname or false.
  */
 protected function _resolveClassName($class)
 {
     $result = App::className($class, 'Model/Behavior', 'Behavior');
     if (!$result) {
         $result = App::className($class, 'ORM/Behavior', 'Behavior');
     }
     return $result;
 }
开发者ID:rederlo,项目名称:cakephp,代码行数:16,代码来源:BehaviorRegistry.php

示例11: _resolveClassName

 /**
  * Resolve a filter class name.
  *
  * Part of the template method for Cake\Core\ObjectRegistry::load()
  *
  * @param  string       $class Partial class name to resolve.
  * @return string|false Either the correct class name or false.
  */
 protected function _resolveClassName($class)
 {
     $result = App::className($class, 'Model/Filter', 'Filter');
     if ($result || strpos($class, '.') !== false) {
         return $result;
     }
     return App::className('PlumSearch.' . $class, 'Model/Filter', 'Filter');
 }
开发者ID:kajko1973,项目名称:plum_search,代码行数:16,代码来源:FilterRegistry.php

示例12: generateSender

 /**
  * generate Encount Sender
  *
  * @access private
  * @author sakuragawa
  */
 private function generateSender($name)
 {
     $class = App::className($name, 'Sender');
     if (!class_exists($class)) {
         throw new InvalidArgumentException(sprintf('Encount sender "%s" was not found.', $class));
     }
     return new $class();
 }
开发者ID:fusic,项目名称:encount,代码行数:14,代码来源:EncountErrorHandler.php

示例13: initialize

 /**
  * {@inheritDoc}
  *
  * @param array $config Configuration
  * @return void
  */
 public function initialize(array $config)
 {
     $this->alias('Permissions');
     $this->table('aros_acos');
     $this->belongsTo('Aros', ['className' => App::className('Acl.ArosTable', 'Model/Table')]);
     $this->belongsTo('Acos', ['className' => App::className('Acl.AcosTable', 'Model/Table')]);
     $this->Aro = $this->Aros->target();
     $this->Aco = $this->Acos->target();
 }
开发者ID:cakephp,项目名称:acl,代码行数:15,代码来源:PermissionsTable.php

示例14: _createFilter

 /**
  * Create an instance of a filter.
  *
  * @param string $name The name of the filter to build.
  * @param array $options Constructor arguments/options for the filter.
  * @return \Cake\Routing\DispatcherFilter
  * @throws \Cake\Routing\Exception\MissingDispatcherFilterException When filters cannot be found.
  */
 protected static function _createFilter($name, $options)
 {
     $className = App::className($name, 'Routing/Filter', 'Filter');
     if (!$className) {
         $msg = sprintf('Cannot locate dispatcher filter named "%s".', $name);
         throw new MissingDispatcherFilterException($msg);
     }
     return new $className($options);
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:17,代码来源:DispatcherFactory.php

示例15: buildFilter

 /**
  * Create a single filter
  *
  * @param string $name The name of the filter to build.
  * @param array $config The configuration for the filter.
  * @return \MiniAsset\Filter\FilterInterface
  */
 protected function buildFilter($name, $config)
 {
     $className = App::className($name, 'Filter');
     if (!class_exists($className)) {
         $className = App::className('AssetCompress.' . $name, 'Filter');
     }
     $className = $className ?: $name;
     return parent::buildFilter($className, $config);
 }
开发者ID:markstory,项目名称:asset_compress,代码行数:16,代码来源:Factory.php


注:本文中的Cake\Core\App::className方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。