本文整理汇总了PHP中Component::setChild方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::setChild方法的具体用法?PHP Component::setChild怎么用?PHP Component::setChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Component
的用法示例。
在下文中一共展示了Component::setChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param string $uri base URI for this component
* @param string $namespace this applications base namespace
* @param array $paths path to the application component
* @param Component $parent parent Component instance
* @param Fuel\Config\Datacontainer $config Config Container instance
* @param Input $input Input Container instance
* @param Composer\ClassLoader $autoloader Autoloader instance
* @param InjectionFactory $factory factory object to construct external objects
*
* @since 2.0.0
*/
public function __construct($app, $uri, $namespace, $paths, $routeable, $parent, $config, $input, $autoloader, InjectionFactory $factory)
{
// store the component object factory
$this->factory = $factory;
// store the app
$this->app = $app;
// unify the URI
$this->uri = trim($uri, '/');
// and the namespace
$this->namespace = trim($namespace, '\\');
// and the routeable flag
$this->routeable = (bool) $routeable;
// TODO: needs a better solution than hardcoding paths!
// process and verify the paths
foreach ($paths = (array) $paths as $path) {
// get what we think is the root path
$path = realpath($path . DS . '..' . DS);
// check if this is a valid component
if (is_dir($path . DS . 'classes') and !in_array($path, $this->paths)) {
// store it
$this->paths[] = $path;
// and add it to the autoloader if needed
$prefixes = $autoloader->getPrefixesPsr4();
if (!isset($prefixes[$this->namespace . '\\']) or !in_array($path . DS . 'classes', $prefixes[$this->namespace . '\\'])) {
$autoloader->addPsr4($this->namespace . '\\', $path . DS . 'classes');
}
}
}
// if the parent is a Component too
if ($parent instanceof Component) {
// make a backlink to link parent and child
$parent->setChild($this);
} else {
// setup the global config defaults
$config->addPath(realpath(__DIR__ . DS . '..' . DS . 'defaults') . DS);
// import global data
$input->fromGlobals();
// assign the configuration container to this input instance
$input->setConfig($config);
}
// add the paths to the config
foreach ($this->paths as $path) {
$config->addPath($path . DS);
}
// store the config container
$this->config = $config;
// load the application configuration
$this->config->load('config', null);
// load the file config
$this->config->load('file', true);
// load the lang config
$this->config->load('lang', true);
// store our parent object
$this->parent = $parent ?: $app;
// create the router instance
$this->router = $this->factory->createRouterInstance($this);
// and load any defined routes in this module
$this->loadRoutes();
// store the input instance
$this->input = $input;
// and finally run the component bootstrap if present
$this->runBootstrap();
}