本文整理汇总了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');
}
示例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);
}
}
示例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');
}
示例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));
}
}
示例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));
}
}
示例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];
}
示例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];
}
示例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;
}
示例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();
}
示例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;
}
示例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');
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}