本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例6: testExplode
/**
* @dataProvider provideNames
*/
public function testExplode($classified, $separator, $split, $exploded)
{
$this->assertEquals(KInflector::explode($classified), $exploded);
}
示例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);
}
示例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]);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}