protected function resolve_block_class($name) { $module = $this; $class_name = \ICanBoogie\camelize(\ICanBoogie\underscore($name)) . 'Block'; while ($module) { $try = $module->descriptor[self::T_NAMESPACE] . '\\' . $class_name; if (class_exists($try, true)) { return $try; } $module = $module->parent; } }
/** * Alters the module descriptor. * * @param array $descriptor Descriptor of the module to index. * * @return array The altered descriptor. */ protected function alter_descriptor(array $descriptor) { $id = $descriptor[Descriptor::ID]; $namespace = $descriptor[Descriptor::NS]; # models and active records foreach ($descriptor[Descriptor::MODELS] as $model_id => &$definition) { if (!is_array($definition)) { throw new \InvalidArgumentException(\ICanBoogie\format('Model definition must be array, given: %value.', ['value' => $definition])); } $basename = $id; $separator_position = strrpos($basename, '.'); if ($separator_position) { $basename = substr($basename, $separator_position + 1); } if (empty($definition[Model::NAME])) { $definition[Model::NAME] = self::format_model_name($id, $model_id); } if (empty($definition[Model::ACTIVERECORD_CLASS])) { $definition[Model::ACTIVERECORD_CLASS] = $namespace . '\\' . \ICanBoogie\camelize(\ICanBoogie\singularize($model_id == 'primary' ? $basename : $model_id)); } if (empty($definition[Model::CLASSNAME])) { $definition[Model::CLASSNAME] = $definition[Model::ACTIVERECORD_CLASS] . 'Model'; } } return $descriptor; }