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


PHP KInflector::explode方法代码示例

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


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

示例1: __call

 /**
  * If the method has a format is[A-Z] then it's a behavior name.
  *
  * @param string $method
  * @param array  $arguments
  *
  * @return mixed
  */
 public function __call($method, $arguments = array())
 {
     $parts = KInflector::explode($method);
     if ($parts[0] == 'is' && isset($parts[1])) {
         $behavior = lcfirst(substr($method, 2));
         return !is_null($this->_repository->getBehavior($behavior));
     }
     return parent::__call($method, $arguments);
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:17,代码来源:abstract.php

示例2: __call

 public function __call($method, $arguments)
 {
     if (substr($method, 0, 3) === 'can') {
         $parts = KInflector::explode($method);
         array_shift($parts);
         array_unshift($parts, 'core');
         $permission = implode('.', $parts);
         return $this[$permission];
     }
     return parent::__call($method, $arguments);
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:11,代码来源:permissions.php

示例3: __call

 /**
  * Search the mixin method map and call the method or forward the call to each row for processing.
  * 
  * Function is also capable of checking is a behavior has been mixed successful using is[Behavior] function. If the
  * behavior exists the function will return TRUE, otherwise FALSE.
  *
  * @param  string   $method    The function name
  * @param  array    $arguments The function arguments
  * @throws BadMethodCallException   If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, $arguments)
 {
     $parts = KInflector::explode($method);
     //If the method is of the form is[Bahavior] handle it
     if ($parts[0] == 'is' && isset($parts[1])) {
         if (isset($this->_mixed_methods[$method])) {
             return true;
         }
         return false;
     } else {
         //If the mixed method exists call it for all the rows
         if (isset($this->_mixed_methods[$method])) {
             foreach ($this as $i => $row) {
                 $row->__call($method, $arguments);
             }
             return $this;
         }
     }
     throw new BadMethodCallException('Call to undefined method :' . $method);
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:31,代码来源:abstract.php

示例4: __call

 /**
  * Search the mixin method map and call the method or trigger an error
  *
  * This functions overloads KDatabaseRowAbstract::__call and implements
  * a just in time mixin strategy. Available table behaviors are only mixed
  * when needed.
  *
  * @param  string 	The function name
  * @param  array  	The function arguments
  * @throws BadMethodCallException 	If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, array $arguments)
 {
     if ($this->isConnected()) {
         $parts = KInflector::explode($method);
         //Check if a behavior is mixed
         if ($parts[0] == 'is' && isset($parts[1])) {
             if (!isset($this->_mixed_methods[$method])) {
                 //Lazy mix behaviors
                 $behavior = strtolower($parts[1]);
                 if ($this->getTable()->hasBehavior($behavior)) {
                     $this->mixin($this->getTable()->getBehavior($behavior));
                     return true;
                 }
                 return false;
             }
             return true;
         }
     }
     return parent::__call($method, $arguments);
 }
开发者ID:janssit,项目名称:www.ondernemenddiest.be,代码行数:32,代码来源:table.php

示例5: __call

 /**
  * Add a command by it's name
  *
  * @param   string  Method name
  * @param   array   Array containing all the arguments for the original call
  * @see addCommand()
  */
 public function __call($method, $args)
 {
     $parts = KInflector::explode($method);
     if ($parts[0] == 'add' && isset($parts[1])) {
         $config = isset($args[0]) ? $args[0] : array();
         $this->addCommand(strtolower($parts[1]), $config);
         return $this;
     }
     return parent::__call($method, $args);
 }
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:17,代码来源:abstract.php

示例6: testExplode

 /**
  * @dataProvider provideNames
  */
 public function testExplode($classified, $separator, $split, $exploded)
 {
     $this->assertEquals(KInflector::explode($classified), $exploded);
 }
开发者ID:janssit,项目名称:www.rvproductions.be,代码行数:7,代码来源:KInflectorTest.php

示例7: __call

    /**
     * Execute a controller action by it's name. 
	 *
	 * Function is also capable of checking is a behavior has been mixed succesfully
	 * using is[Behavior] function. If the behavior exists the function will return 
	 * TRUE, otherwise FALSE.
     * 
     * @param   string  Method name
     * @param   array   Array containing all the arguments for the original call
     * @see execute()
     */
    public function __call($method, $args)
    {
        //Handle action alias method
        if(in_array($method, $this->getActions())) 
        {
            //Get the data
            $data = !empty($args) ? $args[0] : array();
            
            //Create a context object
            if(!($data instanceof KCommandContext))
            {
                $context = $this->getCommandContext();
                $context->data   = $data;
                $context->result = false;
            } 
            else $context = $data;
            
            //Execute the action
            return $this->execute($method, $context);
        }
        
        //Check if a behavior is mixed
		$parts = KInflector::explode($method);

		if($parts[0] == 'is' && isset($parts[1]))
		{
		    //Lazy mix behaviors
		    $behavior = strtolower($parts[1]);
		    
            if(!isset($this->_mixed_methods[$method]))
            { 
                if($this->hasBehavior($behavior)) 
                {
                    $this->mixin($this->getBehavior($behavior));
                    return true;
		        }
		  
			    return false;
            }
            
            return true;
		}
     
        return parent::__call($method, $args);
    }
开发者ID:raeldc,项目名称:com_learn,代码行数:56,代码来源:abstract.php

示例8: __call

 /**
  * The captured method is used as the attribute of this
  * tag
  *
  * @param $method
  * @param $args
  * @return object LibBaseTemplateHelperHtmlTag class instance
  */
 public function __call($method, $args)
 {
     $parts = KInflector::explode($method);
     $name = implode('-', $parts);
     return $this->set($name, $args[0]);
 }
开发者ID:walteraries,项目名称:anahita,代码行数:14,代码来源:element.php

示例9: __call

 /**
  * Search the behaviors to see if this table behaves as.
  *
  * Function is also capable of checking is a behavior has been mixed succesfully
  * using is[Behavior] function. If the behavior exists the function will return
  * TRUE, otherwise FALSE.
  *
  * @param  string 	The function name
  * @param  array  	The function arguments
  * @throws BadMethodCallException 	If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, $arguments)
 {
     // If the method is of the form is[Bahavior] handle it.
     $parts = KInflector::explode($method);
     if ($parts[0] == 'is' && isset($parts[1])) {
         if ($this->hasBehavior(strtolower($parts[1]))) {
             return true;
         }
         return false;
     }
     return parent::__call($method, $arguments);
 }
开发者ID:janssit,项目名称:www.marlinfishingcanaria.com,代码行数:24,代码来源:abstract.php

示例10: __call

 /**
  * Adds a missed method as $key/$value.
  *
  * @param string $method
  * @param array  $arguments
  * 
  * @return LibBaseTemplateObject
  */
 public function __call($method, $arguments)
 {
     $attribute = implode('-', KInflector::explode($method));
     $this->setAttribute($attribute, $arguments[0], isset($arguments[1]) ? $arguments[1] : null);
     return $this;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:14,代码来源:object.php

示例11: __call

 /**
  * Search the mixin method map and call the method or trigger an error
  *
  * Function is also capable of checking is a behavior has been mixed succesfully
  * using is[Behavior] function. If the behavior exists the function will return 
  * TRUE, otherwise FALSE.
  *
  * @param  string 	The function name
  * @param  array  	The function arguments
  * @throws BadMethodCallException 	If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, array $arguments)
 {
     // If the method is of the form is[Bahavior] handle it.
     $parts = KInflector::explode($method);
     if ($parts[0] == 'is' && isset($parts[1])) {
         if (isset($this->_mixed_methods[$method])) {
             return true;
         }
         return false;
     }
     return parent::__call($method, $arguments);
 }
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:24,代码来源:abstract.php

示例12: __call

 /**
  * If the missed method is implemented by the query object then delegate the call to the query object
  * 
  * @see KObject::__call()
  */
 public function __call($method, $arguments = array())
 {
     $parts = KInflector::explode($method);
     if ($parts[0] == 'is' && isset($parts[1])) {
         $behavior = lcfirst(substr($method, 2));
         return $this->_repository->hasBehavior($behavior);
     }
     //forward a call to the query
     if (method_exists($this->getQuery(), $method) || !$this->_repository->entityMethodExists($method)) {
         $result = call_object_method($this->getQuery(), $method, $arguments);
         if ($result instanceof AnDomainQuery) {
             $result = $this;
         }
     } else {
         $result = parent::__call($method, $arguments);
     }
     return $result;
 }
开发者ID:walteraries,项目名称:anahita,代码行数:23,代码来源:default.php

示例13: __call

 /**
  * Implements magic method. Dynamically mixes a mixin
  * 
  * @param string $method Method name
  * @param array  $args   Array of arugments
  * 
  * @return mixed
  */
 public function __call($method, $args)
 {
     //If the method hasn't been mixed yet, load all the behaviors
     if (!isset($this->_mixed_methods[$method])) {
         $key = 'behavior.' . $method;
         if (!self::_cache($this)->offsetExists($key)) {
             self::_cache($this)->offsetSet($key, false);
             $behaviors = $this->getRepository()->getBehaviors();
             foreach ($behaviors as $behavior) {
                 if (in_array($method, $behavior->getMixableMethods())) {
                     //only mix the mixin that has $method
                     self::_cache($this)->offsetSet($key, $behavior);
                     break;
                 }
             }
         }
         if ($behavior = self::_cache($this)->offsetGet($key)) {
             $this->mixin($behavior);
         }
     }
     $parts = KInflector::explode($method);
     if ($parts[0] == 'is') {
         if (isset($this->_mixed_methods[$method])) {
             return true;
         } else {
             return false;
         }
     }
     if (!isset($this->_mixed_methods[$method])) {
         if ($parts[0] == 'get' || $parts[0] == 'set') {
             $property = lcfirst(KInflector::implode(array_slice($parts, 1)));
             $property = $this->getEntityDescription()->getProperty($property);
             if ($property) {
                 if ($parts[0] == 'get') {
                     return $this->getData($property->getName());
                 } else {
                     return $this->setData($property->getName(), array_shift($args));
                 }
             }
         }
     }
     return parent::__call($method, $args);
 }
开发者ID:walteraries,项目名称:anahita,代码行数:51,代码来源:abstract.php

示例14: get_prefix

/**
 * Return an array of class prefix.
 *
 * @param object $object An object
 * @param array  $config An array of configuration
 *
 * @return array
 */
function get_prefix($object, $config = array())
{
    if (!is_array($config) || is_numeric(key($config))) {
        $config = array('append' => (array) $config);
    }
    $config = array_merge(array('break' => 'K', 'append' => null), $config);
    $classes = array();
    $class = is_string($object) ? $object : get_class($object);
    $break = $config['break'];
    $append = $config['append'];
    while ($class) {
        if (strpos($class, $break) === 0) {
            break;
        }
        $parts = KInflector::explode($class);
        if ($parts[0] == 'lib') {
            $classes[] = 'Com' . ucfirst($parts[1]);
            $classes[] = ucfirst($parts[0]) . ucfirst($parts[1]);
        } elseif ($parts[0] == 'com') {
            $classes[] = ucfirst($parts[0]) . ucfirst($parts[1]);
            $classes[] = 'Lib' . ucfirst($parts[1]);
        } else {
            $classes[] = ucfirst($parts[0]);
        }
        $class = get_parent_class($class);
    }
    $classes = array_unique($classes);
    if ($append) {
        $array = array();
        settype($append, 'array');
        foreach ($classes as $key => $class) {
            foreach ($append as $word) {
                $array[] = $class . $word;
            }
        }
        $classes = $array;
    }
    return $classes;
}
开发者ID:stonyyi,项目名称:anahita,代码行数:47,代码来源:class.php

示例15: __call

 /**
  * Overloaded call function to handle behaviors and forward all 
  * calls to to the object regardless
  *
  * @param  string   The function name
  * @param  array    The function arguments
  * @return mixed The result of the function
  */
 public function __call($method, $arguments)
 {
     $object = $this->getObject();
     $parts = KInflector::explode($method);
     if ($parts[0] == 'is' && isset($parts[1])) {
         $behavior = lcfirst(substr($method, 2));
         return !is_null($this->getRepository()->getBehavior($behavior));
     } else {
         return call_object_method($object, $method, $arguments);
     }
 }
开发者ID:walteraries,项目名称:anahita,代码行数:19,代码来源:onetomany.php


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