protected final function callParent($method_name) { $arg_list = func_get_args(); $method_name = $arg_list[0]; $arg_list = Kit::slice($arg_list, 1); return $this->execute($method_name, $arg_list, TRUE); }
public final function filter(Closure $function) { $arg_list = func_get_args(); if (count($arg_list) > 1) { $arg_list = Kit::slice($arg_list, 1); } else { $arg_list = []; } $result = []; foreach ($this->getEntityList() as $index => $entity) { if (TRUE === call_user_func_array($function, array_merge([$entity], $arg_list, [$index]))) { $result[] = $entity; } } return $this->setEntityList($result); }
public static final function popedList(&$list) { self::ensureList($list); if (0 === count($list)) { throw new UserException('Can not pop from an empty list.'); } return Kit::slice($list, 0, count($list) - 1); }
/** * eg. 'Collection/Content/ResourceCollection' => 'Content/Resource' * eg. 'Entity/Content/ResourceEntity' => 'Content/Resource' */ public static final function getModelPath($model_class_name, $delimiter = '\\') { Kit::ensureString($model_class_name); Kit::ensureString($delimiter); $handler_prefix = self::getHandlerPrefixFromPath($model_class_name); // 'Resource' $word_list = Kit::split($delimiter, $model_class_name); while (Kit::len($word_list) > 0 and 'Model' !== $word_list[0]) { $word_list = Kit::slice($word_list, 1); } $word_list = Kit::slice($word_list, 2); // [ 'Content', 'ResourceCollection' ] Kit::popList($word_list); // [ 'Content' ] $word_list[] = $handler_prefix; // [ 'Content', 'Resource' ] return Kit::join('/', $word_list); // 'Content/Resource' }