• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP namespaceSplit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中namespaceSplit函数的典型用法代码示例。如果您正苦于以下问题:PHP namespaceSplit函数的具体用法?PHP namespaceSplit怎么用?PHP namespaceSplit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: filterAssociations

 /**
  * Returns filtered associations for controllers models. HasMany association are filtered if
  * already existing in BelongsToMany
  *
  * @param Table $model The model to build associations for.
  * @return array associations
  */
 public function filterAssociations(Table $model)
 {
     $belongsToManyJunctionsAliases = $this->belongsToManyJunctionAliases($model);
     $keys = ['BelongsTo', 'HasOne', 'HasMany', 'BelongsToMany'];
     $associations = [];
     foreach ($keys as $type) {
         foreach ($model->associations()->type($type) as $assoc) {
             $target = $assoc->target();
             $assocName = $assoc->name();
             $alias = $target->alias();
             //filter existing HasMany
             if ($type === 'HasMany' && in_array($alias, $belongsToManyJunctionsAliases)) {
                 continue;
             }
             $targetClass = get_class($target);
             list(, $className) = namespaceSplit($targetClass);
             $navLink = true;
             $modelClass = get_class($model);
             if ($modelClass !== 'Cake\\ORM\\Table' && $targetClass === $modelClass) {
                 $navLink = false;
             }
             $className = preg_replace('/(.*)Table$/', '\\1', $className);
             if ($className === '') {
                 $className = $alias;
             }
             try {
                 $associations[$type][$assocName] = ['property' => $assoc->property(), 'variable' => Inflector::variable($assocName), 'primaryKey' => (array) $target->primaryKey(), 'displayField' => $target->displayField(), 'foreignKey' => $assoc->foreignKey(), 'alias' => $alias, 'controller' => $className, 'fields' => $target->schema()->columns(), 'navLink' => $navLink];
             } catch (Exception $e) {
                 // Do nothing it could be a bogus association name.
             }
         }
     }
     return $associations;
 }
开发者ID:AmuseXperience,项目名称:api,代码行数:41,代码来源:AssociationFilter.php


示例2: elementName

 /**
  * Get the element name for the panel.
  *
  * @return string
  */
 public function elementName()
 {
     list($ns, $name) = namespaceSplit(get_class($this));
     if ($this->plugin) {
         return $this->plugin . '.' . Inflector::underscore($name);
     }
     return Inflector::underscore($name);
 }
开发者ID:fabioalvaro,项目名称:cakexuxu,代码行数:13,代码来源:DebugPanel.php


示例3: _repository

 /**
  * Gets the repository for this entity
  *
  * @param EntityInterface $entity
  * @return Table
  */
 protected function _repository($entity)
 {
     $source = $entity->source();
     if ($source === null) {
         list(, $class) = namespaceSplit(get_class($entity));
         $source = Inflector::pluralize($class);
     }
     return TableRegistry::get($source);
 }
开发者ID:cakeplugins,项目名称:api,代码行数:15,代码来源:TransformerAbstract.php


示例4: method

 /**
  * Returns the database method name or sets a new one
  *
  * @param string|null $method the new method name
  * @return string
  */
 public function method($method = null)
 {
     if ($method !== null) {
         $this->_method = $method;
     }
     if ($this->_method === null) {
         $method = namespaceSplit(get_class($this));
         $method = substr(end($method), 0, -6);
         $this->_method = Inflector::underscore($method);
     }
     return $this->_method;
 }
开发者ID:cakedc,项目名称:cakephp-oracle-driver,代码行数:18,代码来源:Method.php


示例5: __construct

 public function __construct(MacroRegistry $macroRegistry, array $config = [], $name = null)
 {
     if ($this->name === null && $name === null) {
         list(, $name) = namespaceSplit(get_class($this));
         $name = substr($name, 0, -5);
     }
     if ($name !== null) {
         $this->name = $name;
     }
     $this->config($config);
     $this->modelFactory('Table', ['Cake\\ORM\\TableRegistry', 'get']);
     $modelClass = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
     $this->_setModelClass($modelClass);
 }
开发者ID:cvo-technologies,项目名称:macro,代码行数:14,代码来源:Macro.php


示例6: render

 /**
  * Renders the response for the exception.
  *
  * @return Response The response to be sent.
  */
 public function render($exception)
 {
     $exception = $exception instanceof PHP7ErrorException ? $exception->getError() : $exception;
     list(, $baseClass) = namespaceSplit(get_class($exception));
     if (substr($baseClass, -9) === 'Exception') {
         $baseClass = substr($baseClass, 0, -9);
     }
     $action = (new Text($baseClass))->camelBackize() ?: 'error500';
     $class = Core::className('Error', 'Controller', 'Controller');
     $controller = new $class();
     if (!in_array($action, get_class_methods($controller))) {
         $action = "processError";
     }
     return $controller->callAction($action, ["exception" => $exception, "request" => Router::getInstance()->request()]);
 }
开发者ID:coretyson,项目名称:coretyson,代码行数:20,代码来源:ExceptionRenderer.php


示例7: type

 /**
  * Get an array of associations matching a specific type.
  *
  * @param string $class The type of associations you want. For example 'BelongsTo'
  * @return array An array of Association objects.
  */
 public function type($class)
 {
     $out = array_filter($this->_items, function ($assoc) use($class) {
         list($ns, $name) = namespaceSplit(get_class($assoc));
         return $class === $name;
     });
     return array_values($out);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:14,代码来源:Associations.php


示例8: _prepare

 /**
  * Prepare some additional data from the context.
  *
  * If the table option was provided to the constructor and it
  * was a string, ORM\TableRegistry will be used to get the correct table instance.
  *
  * If an object is provided as the table option, it will be used as is.
  *
  * If no table option is provided, the table name will be derived based on
  * naming conventions. This inference will work with a number of common objects
  * like arrays, Collection objects and ResultSets.
  *
  * @return void
  * @throws \RuntimeException When a table object cannot be located/inferred.
  */
 protected function _prepare()
 {
     $table = $this->_context['table'];
     $entity = $this->_context['entity'];
     if (empty($table)) {
         if (is_array($entity) || $entity instanceof Traversable) {
             $entity = (new Collection($entity))->first();
         }
         $isEntity = $entity instanceof Entity;
         if ($isEntity) {
             $table = $entity->source();
         }
         if (!$table && $isEntity && get_class($entity) !== 'Cake\\ORM\\Entity') {
             list($ns, $entityClass) = namespaceSplit(get_class($entity));
             $table = Inflector::pluralize($entityClass);
         }
     }
     if (is_string($table)) {
         $table = TableRegistry::get($table);
     }
     if (!is_object($table)) {
         throw new \RuntimeException('Unable to find table class for current entity');
     }
     $this->_isCollection = is_array($entity) || $entity instanceof Traversable;
     $alias = $this->_rootName = $table->alias();
     $this->_tables[$alias] = $table;
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:42,代码来源:EntityContext.php


示例9: __construct

 /**
  * Constructor.
  *
  * Sets a number of properties based on conventions if they are empty. To override the
  * conventions CakePHP uses you can define properties in your class declaration.
  *
  * @param \Cake\Network\Request|null $request Request object for this controller. Can be null for testing,
  *   but expect that features that use the request parameters will not work.
  * @param \Cake\Network\Response|null $response Response object for this controller.
  * @param string|null $name Override the name useful in testing when using mocks.
  * @param \Cake\Event\EventManager|null $eventManager The event manager. Defaults to a new instance.
  */
 public function __construct(Request $request = null, Response $response = null, $name = null, $eventManager = null)
 {
     if ($this->name === null && $name === null) {
         list(, $name) = namespaceSplit(get_class($this));
         $name = substr($name, 0, -10);
     }
     if ($name !== null) {
         $this->name = $name;
     }
     if (!$this->viewPath) {
         $viewPath = $this->name;
         if (isset($request->params['prefix'])) {
             $prefixes = array_map('Cake\\Utility\\Inflector::camelize', explode('/', $request->params['prefix']));
             $viewPath = implode(DS, $prefixes) . DS . $viewPath;
         }
         $this->viewPath = $viewPath;
     }
     if (!$request instanceof Request) {
         $request = new Request();
     }
     $this->setRequest($request);
     if (!$response instanceof Response) {
         $response = new Response();
     }
     $this->response = $response;
     if ($eventManager) {
         $this->eventManager($eventManager);
     }
     $this->modelFactory('Table', ['Cake\\ORM\\TableRegistry', 'get']);
     $modelClass = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
     $this->_setModelClass($modelClass);
     $this->initialize();
     $this->_mergeControllerVars();
     $this->_loadComponents();
     $this->eventManager()->on($this);
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:48,代码来源:Controller.php


示例10: _findTasks

 /**
  * Append matching tasks in $path to the $tasks array.
  *
  * @param array $tasks The task list to modify and return.
  * @param string $path The base path to look in.
  * @param string $namespace The base namespace.
  * @param string|null $prefix The prefix to append.
  * @return array Updated tasks.
  */
 protected function _findTasks($tasks, $path, $namespace, $prefix = null)
 {
     $path .= 'Shell/Task';
     if (!is_dir($path)) {
         return $tasks;
     }
     $candidates = $this->_findClassFiles($path, $namespace);
     $classes = $this->_findTaskClasses($candidates);
     foreach ($classes as $class) {
         list(, $name) = namespaceSplit($class);
         $name = substr($name, 0, -4);
         $fullName = ($prefix ? $prefix . '.' : '') . $name;
         $tasks[$name] = $fullName;
     }
     return $tasks;
 }
开发者ID:hasegawa-tomoki,项目名称:tsvio,代码行数:25,代码来源:TsvioShell.php


示例11: _method

 /**
  * Get method name
  *
  * @param Exception $exception Exception instance.
  * @return string
  */
 protected function _method(Exception $exception)
 {
     $exception = $this->_unwrap($exception);
     list(, $baseClass) = namespaceSplit(get_class($exception));
     if (substr($baseClass, -9) === 'Exception') {
         $baseClass = substr($baseClass, 0, -9);
     }
     $method = Inflector::variable($baseClass) ?: 'error500';
     return $this->method = $method;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:16,代码来源:ExceptionRenderer.php


示例12: _method

 /**
  * Get method name
  *
  * @param \Exception $exception Exception instance.
  * @return string
  */
 protected function _method(\Exception $exception)
 {
     list(, $baseClass) = namespaceSplit(get_class($exception));
     $baseClass = substr($baseClass, 0, -9);
     $method = Inflector::variable($baseClass) ?: 'error500';
     return $this->method = $method;
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:13,代码来源:ExceptionRenderer.php


示例13: name

 /**
  * Returns the type name name or sets a new one
  *
  * @param string $name the new type name
  * @return string
  */
 public function name($name = null)
 {
     if ($name !== null) {
         $this->_name = $name;
     }
     if ($this->_name === null) {
         $name = namespaceSplit(get_class($this));
         $name = substr(end($name), 0, -4);
         if (empty($name)) {
             $name = '*';
         }
         $this->_name = Inflector::underscore($name);
     }
     return $this->_name;
 }
开发者ID:jeffersongoncalves,项目名称:elastic-search,代码行数:21,代码来源:Type.php


示例14: _extractId

 /**
  * Extract the id from the theme class name.
  *
  * @return string
  */
 protected function _extractId()
 {
     list(, $className) = namespaceSplit(get_class($this));
     $id = explode('Theme', $className)[0];
     if (!$className || !$id) {
         user_error(__d('wasabi_cms', 'The theme class {0} has an invalid name. The name has to end with "Theme".', $className));
     }
     return $id;
 }
开发者ID:wasabi-cms,项目名称:cms,代码行数:14,代码来源:Theme.php


示例15: _currentTable

 /**
  * Return current table in camelCase form.
  * It adds plugin name as a prefix.
  *
  * @return string Table Name along with its prefix if found.
  */
 protected function _currentTable()
 {
     list($namespace, $alias) = namespaceSplit(get_class($this));
     $alias = substr($alias, 0, -5);
     list($plugin) = explode('\\', $namespace);
     if ($plugin === 'App') {
         return Inflector::camelize($alias);
     }
     return Inflector::camelize($plugin . '.' . $alias);
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:16,代码来源:Table.php


示例16: testDriverOptionClassNameSupport

 /**
  * Tests that the `driver` option supports the short classname/plugin syntax.
  *
  * @return void
  */
 public function testDriverOptionClassNameSupport()
 {
     $connection = new Connection(['driver' => 'TestDriver']);
     $this->assertInstanceOf('\\TestApp\\Database\\Driver\\TestDriver', $connection->driver());
     $connection = new Connection(['driver' => 'TestPlugin.TestDriver']);
     $this->assertInstanceOf('\\TestPlugin\\Database\\Driver\\TestDriver', $connection->driver());
     list(, $name) = namespaceSplit(get_class($this->connection->driver()));
     $connection = new Connection(['driver' => $name]);
     $this->assertInstanceOf(get_class($this->connection->driver()), $connection->driver());
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:15,代码来源:ConnectionTest.php


示例17: info

 /**
  * Returns an array of information of this field. Valid options are:
  *
  * - `type` (string): Type of data this field stores, possible values are:
  *   datetime, decimal, int, text, varchar.
  *
  * - `name` (string): Human readable name of this field. ex. `Selectbox`
  *   Defaults to class name.
  *
  * - `description` (string): Something about what this field does or allows
  *   to do. Defaults to class name.
  *
  * - `hidden` (bool): If set to false users can not use this field via
  *   Field UI. Defaults to true, users can use it via Field UI.
  *
  * - `maxInstances` (int): Maximum number instances of this field a table
  *   can have. Set to 0 to indicates no limits. Defaults to 0.
  *
  * - `searchable` (bool): Whether this field can be searched using WHERE
  *   clauses.
  *
  * @return array
  */
 public function info()
 {
     list(, $handlerName) = namespaceSplit(get_class($this));
     return ['type' => 'varchar', 'name' => (string) $handlerName, 'description' => (string) $handlerName, 'hidden' => false, 'maxInstances' => 0, 'searchable' => true];
 }
开发者ID:quickapps-plugins,项目名称:field,代码行数:28,代码来源:Handler.php


示例18: _associations

 /**
  * Returns associations for controllers models.
  *
  * @param Table $model The model to build associations for.
  * @return array associations
  */
 protected function _associations(Table $model)
 {
     $keys = ['BelongsTo', 'HasOne', 'HasMany', 'BelongsToMany'];
     $associations = [];
     foreach ($keys as $type) {
         foreach ($model->associations()->type($type) as $assoc) {
             $target = $assoc->target();
             $assocName = $assoc->name();
             $alias = $target->alias();
             $targetClass = get_class($target);
             list(, $className) = namespaceSplit($targetClass);
             $modelClass = get_class($model);
             if ($modelClass !== 'Cake\\ORM\\Table' && $targetClass === $modelClass) {
                 continue;
             }
             $className = preg_replace('/(.*)Table$/', '\\1', $className);
             if ($className === '') {
                 $className = $alias;
             }
             $associations[$type][$assocName] = ['property' => $assoc->property(), 'variable' => Inflector::variable($assocName), 'primaryKey' => (array) $target->primaryKey(), 'displayField' => $target->displayField(), 'foreignKey' => $assoc->foreignKey(), 'alias' => $alias, 'controller' => $className, 'fields' => $target->schema()->columns()];
         }
     }
     return $associations;
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:30,代码来源:ViewTask.php


示例19: __toString

 /**
  * Magic __toString() method to get the CacheEngine's name
  *
  * @return string Returns the CacheEngine's name
  */
 public function __toString()
 {
     if (!empty($this->_engine)) {
         list($ns, $class) = namespaceSplit(get_class($this->_engine));
         return str_replace('Engine', '', $class);
     }
     return $this->_config['className'];
 }
开发者ID:jeremyharris,项目名称:debug_kit,代码行数:13,代码来源:DebugEngine.php


示例20: testNamespaceSplit

 /**
  * test namespaceSplit
  *
  * @return void
  */
 public function testNamespaceSplit()
 {
     $result = namespaceSplit('Something');
     $this->assertEquals(['', 'Something'], $result);
     $result = namespaceSplit('\\Something');
     $this->assertEquals(['', 'Something'], $result);
     $result = namespaceSplit('Cake\\Something');
     $this->assertEquals(['Cake', 'Something'], $result);
     $result = namespaceSplit('Cake\\Test\\Something');
     $this->assertEquals(['Cake\\Test', 'Something'], $result);
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:16,代码来源:BasicsTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP natcasesort函数代码示例发布时间:2022-05-15
下一篇:
PHP nameof函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap