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


PHP ClassRegistry::map方法代码示例

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


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

示例1: __construct

 /**
  *  Constructs this Shell instance.
  *
  */
 function __construct(&$dispatch)
 {
     $vars = array('params', 'args', 'shell', 'shellCommand' => 'command');
     foreach ($vars as $key => $var) {
         if (is_string($key)) {
             $this->{$var} =& $dispatch->{$key};
         } else {
             $this->{$var} =& $dispatch->{$var};
         }
     }
     if ($this->name == null) {
         $this->name = get_class($this);
     }
     if ($this->alias == null) {
         $this->alias = $this->name;
     }
     ClassRegistry::addObject($this->name, $this);
     ClassRegistry::map($this->name, $this->alias);
     if (!PHP5 && isset($this->args[0])) {
         if (strpos($this->name, strtolower(Inflector::camelize($this->args[0]))) !== false) {
             $dispatch->shiftArgs();
         }
         if (strtolower($this->command) == strtolower(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
             $dispatch->shiftArgs();
         }
     }
     $this->Dispatch =& $dispatch;
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:32,代码来源:shell.php

示例2: loadTasks

 /**
  * Loads tasks defined in var $tasks
  *
  * @return bool
  * @access public
  */
 function loadTasks()
 {
     if ($this->tasks === null || $this->tasks === false) {
         return;
     }
     if ($this->tasks !== true && !empty($this->tasks)) {
         $tasks = $this->tasks;
         if (!is_array($tasks)) {
             $tasks = array($tasks);
         }
         foreach ($tasks as $taskName) {
             $loaded = false;
             foreach ($this->Dispatch->shellPaths as $path) {
                 $taskPath = $path . 'tasks' . DS . Inflector::underscore($taskName) . '.php';
                 if (file_exists($taskPath)) {
                     $loaded = true;
                     break;
                 }
             }
             if ($loaded) {
                 $taskKey = Inflector::underscore($taskName);
                 $taskClass = Inflector::camelize($taskName . 'Task');
                 if (!class_exists($taskClass)) {
                     require_once $taskPath;
                 }
                 if (ClassRegistry::isKeySet($taskKey)) {
                     $this->taskNames[] = $taskName;
                     if (!PHP5) {
                         $this->{$taskName} =& ClassRegistry::getObject($taskKey);
                         ClassRegistry::map($taskName, $taskKey);
                     } else {
                         $this->{$taskName} = ClassRegistry::getObject($taskKey);
                         ClassRegistry::map($taskName, $taskKey);
                     }
                 } else {
                     $this->taskNames[] = $taskName;
                     if (!PHP5) {
                         $this->{$taskName} =& new $taskClass($this->Dispatch);
                     } else {
                         $this->{$taskName} = new $taskClass($this->Dispatch);
                     }
                 }
                 if (!isset($this->{$taskName})) {
                     $this->err("Task '" . $taskName . "' could not be loaded");
                     exit;
                 }
             } else {
                 $this->err("Task '" . $taskName . "' could not be found");
                 exit;
             }
         }
     }
     return false;
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:60,代码来源:shell.php

示例3: __construct

 /**
  *  Constructs this Shell instance.
  *
  */
 public function __construct(&$dispatch)
 {
     $vars = array('params', 'args', 'shell', 'shellCommand' => 'command');
     foreach ($vars as $key => $var) {
         if (is_string($key)) {
             $this->{$var} = $dispatch->{$key};
         } else {
             $this->{$var} = $dispatch->{$var};
         }
     }
     if ($this->name == null) {
         $this->name = get_class($this);
     }
     if ($this->alias == null) {
         $this->alias = $this->name;
     }
     ClassRegistry::addObject($this->name, $this);
     ClassRegistry::map($this->name, $this->alias);
     $this->Dispatch = $dispatch;
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:24,代码来源:shell.php

示例4: __constructLinkedModel

 /**
  * Private helper method to create associated models of given class.
  * @param string $assoc
  * @param string $className Class name
  * @param mixed $id Primary key ID of linked model
  * @param string $table Database table associated with linked model
  * @param string $ds Name of DataSource the model should be bound to
  * @deprecated $this->$className use $this->$assoc instead. $assoc is the 'key' in the associations array;
  * 	examples: var $hasMany = array('Assoc' => array('className' => 'ModelName'));
  * 					usage: $this->Assoc->modelMethods();
  *
  * 				var $hasMany = array('ModelName');
  * 					usage: $this->ModelName->modelMethods();
  * @access private
  */
 function __constructLinkedModel($assoc, $className = null)
 {
     $colKey = Inflector::underscore($assoc);
     if (empty($className)) {
         $className = $assoc;
     }
     if (!class_exists($className)) {
         if (!loadModel($className)) {
             return $this->cakeError('missingModel', array(array('className' => $className)));
         }
     }
     $duplicate = false;
     if (ClassRegistry::isKeySet($colKey)) {
         $model = ClassRegistry::getObject($colKey);
         if (is_a($model, $className)) {
             $duplicate = true;
         }
         unset($model);
     }
     if ($duplicate === true) {
         if (!PHP5) {
             $this->{$assoc} =& ClassRegistry::getObject($colKey);
             ClassRegistry::map($assoc, $colKey);
         } else {
             $this->{$assoc} = ClassRegistry::getObject($colKey);
             ClassRegistry::map($assoc, $colKey);
         }
     } else {
         $model = array('name' => $className, 'alias' => $assoc);
         if (!PHP5) {
             $this->{$assoc} =& new $className($model);
         } else {
             $this->{$assoc} = new $className($model);
         }
     }
     $this->alias[$assoc] = $this->{$assoc}->table;
     $this->tableToModel[$this->{$assoc}->table] = $className;
     $this->modelToTable[$assoc] = $this->{$assoc}->table;
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:54,代码来源:model.php

示例5:

<?php

/**
 * CakePHP Container Interop Plugin initialization.
 *
 * Handles registering initialized container in ClassRegistry\
 */
use Interop\Container\ContainerInterface;
App::uses('ClassRegistry', 'Utility');
$containerFile = Configure::read(ContainerInterface::CLASS) ?: APP . 'Config/container.php';
ClassRegistry::addObject(ContainerInterface::CLASS, require $containerFile);
ClassRegistry::map('container', ContainerInterface::CLASS);
开发者ID:eimanavicius,项目名称:cakephp-container-interop,代码行数:12,代码来源:bootstrap.php

示例6: array

 /**
  * Get instance of model for translations
  *
  * @return object
  */
 function &translateModel(&$model)
 {
     if (!isset($this->runtime[$model->name]['model'])) {
         if (!isset($model->translateModel) || empty($model->translateModel)) {
             $className = 'I18nModel';
         } else {
             $className = $model->translateModel;
             if (!class_exists($className) && !loadModel($className)) {
                 return $this->cakeError('missingModel', array(array('className' => $className)));
             }
         }
         if (ClassRegistry::isKeySet($className)) {
             if (PHP5) {
                 $this->runtime[$model->name]['model'] = ClassRegistry::getObject($className);
             } else {
                 $this->runtime[$model->name]['model'] =& ClassRegistry::getObject($className);
             }
         } else {
             if (PHP5) {
                 $this->runtime[$model->name]['model'] = new $className();
             } else {
                 $this->runtime[$model->name]['model'] =& new $className();
             }
             ClassRegistry::addObject($className, $this->runtime[$model->name]['model']);
             ClassRegistry::map($className, $className);
         }
     }
     return $this->runtime[$model->name]['model'];
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:34,代码来源:translate.php


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