本文整理汇总了PHP中ObjectConfig::unbox方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectConfig::unbox方法的具体用法?PHP ObjectConfig::unbox怎么用?PHP ObjectConfig::unbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectConfig
的用法示例。
在下文中一共展示了ObjectConfig::unbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param object An optional ObjectConfig object with configuration options
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
//Set the media url
if (!$config->media_url instanceof HttpUrlInterface) {
$this->_mediaurl = $this->getObject('lib:http.url', array('url' => $config->media_url));
} else {
$this->_mediaurl = $config->media_url;
}
//Set the auto assign state
$this->_auto_assign = $config->auto_assign;
//Set the data
$this->_data = ObjectConfig::unbox($config->data);
//Set the user-defined escaping callback
$this->setEscape($config->escape);
//Set the layout
$this->setLayout($config->layout);
//Set the template object
$this->_template = $config->template;
//Attach the template filters
$filters = (array) ObjectConfig::unbox($config->template_filters);
foreach ($filters as $key => $value) {
if (is_numeric($key)) {
$this->getTemplate()->attachFilter($value);
} else {
$this->getTemplate()->attachFilter($key, $value);
}
}
//Add alias filter for media:// namespaced
$this->getTemplate()->getFilter('alias')->addAlias(array('media://' => (string) $this->_mediaurl . '/'), TemplateFilter::MODE_COMPILE | TemplateFilter::MODE_RENDER);
}
示例2: __construct
/**
* Constructor.
*
* @param ObjectConfig $config Configuration options
*/
public function __construct(ObjectConfig $config)
{
//Set the object manager
if (isset($config->object_manager)) {
$this->__object_manager = $config->object_manager;
}
//Set the object identifier
if (isset($config->object_identifier)) {
$this->__object_identifier = $config->object_identifier;
}
//Initialise the object
$this->_initialize($config);
//Add the mixins
$mixins = (array) ObjectConfig::unbox($config->mixins);
foreach ($mixins as $key => $value) {
if (is_numeric($key)) {
$this->mixin($value);
} else {
$this->mixin($key, $value);
}
}
//Register the decorators
$decorators = (array) ObjectConfig::unbox($config->decorators);
foreach ($decorators as $key => $value) {
if (is_numeric($key)) {
$this->getIdentifier()->getDecorators()->append(array($value));
} else {
$this->getIdentifier()->getDecorators()->append(array($key, $value));
}
}
//Set the object config
$this->__object_config = $config;
}
示例3: buildAttributes
/**
* Build a string with xml style attributes from an array of key/value pairs
*
* @param mixed $array The array of Key/Value pairs for the attributes
* @return string String containing xml style attributes
*/
public function buildAttributes($array)
{
$output = array();
if ($array instanceof ObjectConfig) {
$array = ObjectConfig::unbox($array);
}
if (is_array($array)) {
foreach ($array as $key => $item) {
if (is_array($item)) {
if (empty($item)) {
continue;
}
$item = implode(' ', $item);
}
if (is_bool($item)) {
if ($item === false) {
continue;
}
$item = $key;
}
$output[] = $key . '="' . str_replace('"', '"', $item) . '"';
}
}
return implode(' ', $output);
}
示例4: __construct
/**
* Constructor
*
* @param ObjectConfig $config A ObjectConfig object with optional configuration options
* @return Object
*/
public function __construct(ObjectConfig $config)
{
//Set the object manager
if (!$config->object_manager instanceof ObjectManagerInterface) {
throw new \InvalidArgumentException('object_manager [ObjectManagerInterface] config option is required, "' . gettype($config->object_manager) . '" given.');
} else {
$this->__object_manager = $config->object_manager;
}
//Set the object identifier
if (!$config->object_identifier instanceof ObjectIdentifierInterface) {
throw new \InvalidArgumentException('object_identifier [ObjectIdentifierInterface] config option is required, "' . gettype($config->object_identifier) . '" given.');
} else {
$this->__object_identifier = $config->object_identifier;
}
//Initialise the object
$this->_initialize($config);
//Set the object config
$this->__object_config = $config;
//Add the mixins
$mixins = (array) ObjectConfig::unbox($config->mixins);
foreach ($mixins as $key => $value) {
if (is_numeric($key)) {
$this->mixin($value);
} else {
$this->mixin($key, $value);
}
}
}
示例5: invokeHelper
/**
* Invoke a template helper
*
* This function accepts a partial identifier, in the form of helper.method or schema:package.helper.method. If
* a partial identifier is passed a full identifier will be created using the template identifier.
*
* If the state have the same string keys, then the parameter value for that key will overwrite the state.
*
* @param string $identifier Name of the helper, dot separated including the helper function to call
* @param array $params An optional associative array of functions parameters to be passed to the helper
* @return string Helper output
* @throws \BadMethodCallException If the helper function cannot be called.
*/
public function invokeHelper($identifier, $params = array())
{
//Get the function and helper based on the identifier
$parts = explode('.', $identifier);
$function = array_pop($parts);
$identifier = array_pop($parts);
//Handle schema:package.helper.function identifiers
if (!empty($parts)) {
$identifier = implode('.', $parts) . '.template.helper.' . $identifier;
}
//Create the complete identifier if a partial identifier was passed
if (is_string($identifier) && strpos($identifier, '.') === false) {
$helper = $this->getMixer()->getIdentifier()->toArray();
if ($helper['type'] != 'lib') {
$helper['path'] = array('template', 'helper');
} else {
$helper['path'] = array('helper');
}
$helper['name'] = $identifier;
} else {
$helper = $this->getIdentifier($identifier);
}
$helper = $this->getObject('template.helper.factory')->createHelper($helper, ObjectConfig::unbox($params));
//Call the helper function
if (!is_callable(array($helper, $function))) {
throw new \BadMethodCallException(get_class($helper) . '::' . $function . ' not supported.');
}
//Merge the parameters if helper asks for it
if ($helper instanceof TemplateHelperParameterizable) {
$params = array_merge($this->getParameters()->toArray(), $params);
}
return $helper->{$function}($params);
}
示例6: __construct
/**
* Constructor
*
* @param ObjectConfig|null $config An optional ObjectConfig object with configuration options
* @return UserSession
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
//Session write and close handlers are called after destructing objects since PHP 5.0.5.
if (version_compare(phpversion(), '5.4.0', '>=')) {
session_register_shutdown();
} else {
register_shutdown_function('session_write_close');
}
//Set the session options
$this->setOptions($config->options);
//Set the session name
if (!empty($config->name)) {
$this->setName($config->name);
}
//Set the session identifier
if (!empty($config->id)) {
$this->setId($config->id);
}
//Set the session namespace
$this->setNamespace($config->namespace);
//Set lifetime time
$this->getContainer('metadata')->setLifetime($config->lifetime);
//Set the session handler
$this->setHandler($config->handler, ObjectConfig::unbox($config));
}
示例7: __construct
/**
* Object constructor
*
* @param ObjectConfig $config Configuration options
* @throws \InvalidArgumentException
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
if (is_null($config->command_chain)) {
throw new \InvalidArgumentException('command_chain [CommandChainInterface] config option is required');
}
//Create a command chain object
$this->__command_chain = $config->command_chain;
//Set the command priority
$this->_priority = $config->priority;
//Add the event subscribers
$handlers = (array) ObjectConfig::unbox($config->command_handlers);
foreach ($handlers as $key => $value) {
if (is_numeric($key)) {
$this->addCommandHandler($value);
} else {
$this->addCommandHandler($key, $value);
}
}
//Add the command callbacks
foreach ($this->getMixer()->getMethods() as $method) {
$match = array();
if (preg_match('/_(after|before)([A-Z]\\S*)/', $method, $match)) {
$this->addCommandCallback($match[1] . '.' . strtolower($match[2]), $method);
}
}
}
示例8: _actionRender
/**
* Return the views output
*
* @param ViewContextTemplate $context A view context object
* @return string The output of the view
*/
protected function _actionRender(ViewContextTemplate $context)
{
$data = ObjectConfig::unbox($context->data);
$path = $this->qualifyLayout($context->layout);
//Render the template
$content = $this->getTemplate()->setParameters($context->parameters)->render($path, $data);
return $content;
}
示例9: __construct
/**
* Constructor
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
* @return ObjectArray
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
$parameters = ObjectConfig::unbox($config->parameters);
foreach ($parameters as $key => $values) {
$this->set($key, $values);
}
}
示例10: __construct
/**
* Constructor.
*
* @param ObjectConfig $config Configuration options
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
$schemes = ObjectConfig::unbox($config->schemes);
foreach (array_reverse($schemes) as $alias => $path) {
$this->addScheme($alias, $path);
}
}
示例11: __construct
/**
* Constructor.
*
* @param ObjectConfig $config Configuration options
*/
public function __construct(ObjectConfig $config = null)
{
parent::__construct($config);
$this->_columns = (array) ObjectConfig::unbox($config->columns);
$this->_separator = $config->separator;
$this->_updatable = $config->updatable;
$this->_length = $config->length;
$this->_unique = $config->unique;
}
示例12: _afterReset
/**
* Recalculate offset
*
* @param ModelContextInterface $context A model context object
* @return void
*/
protected function _afterReset(ModelContextInterface $context)
{
$modified = (array) ObjectConfig::unbox($context->modified);
if (in_array('limit', $modified)) {
$limit = $context->state->limit;
if ($limit) {
$context->state->offset = floor($context->state->offset / $limit) * $limit;
}
}
}
示例13: __construct
/**
* Constructor
*
* Prevent creating instances of this class by making the constructor private
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
//Reset the data
$this->__data = array();
//Register the functions
$functions = ObjectConfig::unbox($config->functions);
foreach ($functions as $name => $callback) {
$this->registerFunction($name, $callback);
}
}
示例14: __construct
/**
* Registers all natively provided mime type resolvers.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
//Register the resolvers
$resolvers = ObjectConfig::unbox($config->resolvers);
foreach ($resolvers as $key => $value) {
if (is_numeric($key)) {
$this->registerResolver($value);
} else {
$this->registerResolver($key, $value);
}
}
}
示例15: __construct
/**
* Constructor
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options.
*/
public function __construct(ObjectConfig $config)
{
parent::__construct($config);
//Add the toolbars
$toolbars = (array) ObjectConfig::unbox($config->toolbars);
foreach ($toolbars as $key => $value) {
if (is_numeric($key)) {
$this->attachToolbar($value);
} else {
$this->attachToolbar($key, $value);
}
}
}