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


PHP namespaceSplit函数代码示例

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


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


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