229 lines
4.4 KiB
PHP
229 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace Trinity\Bundle\ContentManagerBundle\Configuration;
|
|
|
|
class PageConfiguration
|
|
{
|
|
protected $blocks = array();
|
|
|
|
protected $blocksOptions = array();
|
|
|
|
protected $dataModels = array();
|
|
|
|
protected $injectParams = array();
|
|
|
|
protected $ignoreParams = array();
|
|
|
|
protected $defaultController;
|
|
|
|
protected $defaultControllerClass;
|
|
|
|
protected $defaultControllerAction;
|
|
|
|
protected $routeParameter;
|
|
|
|
protected $routeMethod;
|
|
|
|
protected $fieldsets = array();
|
|
|
|
protected $sharedMaxAge = 0;
|
|
|
|
public function setBlock($name, $type = 'Trinity\Bundle\ContentManagerBundle\Form\Type\BlockType', $options = array())
|
|
{
|
|
if (empty($name)) {
|
|
throw new \InvalidArgumentException('You must define a valid block name. None given.');
|
|
}
|
|
|
|
$this->blocks[$name] = new BlockConfiguration($name, $type, $options);
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeBlock($name)
|
|
{
|
|
if (isset($this->blocks[$name])) {
|
|
unset($this->blocks[$name]);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBlock($name)
|
|
{
|
|
return isset($this->blocks[$name]) ? $this->blocks[$name] : null;
|
|
}
|
|
|
|
public function setBlocks(array $blocks)
|
|
{
|
|
$this->blocks = $blocks;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBlocks()
|
|
{
|
|
return $this->blocks;
|
|
}
|
|
|
|
public function hasBlock()
|
|
{
|
|
return count($this->getBlocks()) > 0;
|
|
}
|
|
|
|
public function hasBlocks()
|
|
{
|
|
return $this->hasBlock();
|
|
}
|
|
|
|
/*
|
|
* Data model configuration
|
|
*/
|
|
|
|
public function setDataModel($model, $name)
|
|
{
|
|
if (empty($model)) {
|
|
throw new \InvalidArgumentException('You must define a valid data model. None given.');
|
|
}
|
|
|
|
$this->dataModels[$model] = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setDataModels(array $models)
|
|
{
|
|
$this->dataModels = $models;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDataModels()
|
|
{
|
|
return $this->dataModels;
|
|
}
|
|
|
|
/*
|
|
* Routing configuration
|
|
*/
|
|
public function getDefaultController()
|
|
{
|
|
return $this->defaultController;
|
|
}
|
|
|
|
public function setDefaultController($value)
|
|
{
|
|
$this->defaultController = $value;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDefaultControllerClass()
|
|
{
|
|
return $this->defaultControllerClass;
|
|
}
|
|
|
|
public function setDefaultControllerClass($value)
|
|
{
|
|
$this->defaultControllerClass = $value;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDefaultControllerAction()
|
|
{
|
|
return $this->defaultControllerAction;
|
|
}
|
|
|
|
public function setDefaultControllerAction($value)
|
|
{
|
|
$this->defaultControllerAction = $value;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setRouteParameter($param, $method)
|
|
{
|
|
$this->routeParameter = $param;
|
|
$this->routeMethod = $method;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRouteParameter()
|
|
{
|
|
return array(
|
|
'param' => $this->routeParameter,
|
|
'method' => $this->routeMethod
|
|
);
|
|
}
|
|
|
|
public function setFieldsets(array $fieldsets, array $i18nFieldsets = array())
|
|
{
|
|
$this->fieldsets = $fieldsets;
|
|
$this->i18nFieldsets_ = $i18nFieldsets;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getFieldsets()
|
|
{
|
|
return $this->fieldsets;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $sharedMaxAge
|
|
*/
|
|
public function setSharedMaxAge($sharedMaxAge)
|
|
{
|
|
$this->sharedMaxAge = $sharedMaxAge;
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getSharedMaxAge()
|
|
{
|
|
return $this->sharedMaxAge;
|
|
}
|
|
|
|
public function addInjectParam($param)
|
|
{
|
|
$this->injectParams[] = $param;
|
|
}
|
|
|
|
public function setInjectParams($injectParams)
|
|
{
|
|
$this->injectParams = $injectParams;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getInjectParams()
|
|
{
|
|
return $this->injectParams;
|
|
}
|
|
|
|
public function setIgnoreParams(array $ignoreParams)
|
|
{
|
|
$this->ignoreParams = $ignoreParams;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getIgnoreParams()
|
|
{
|
|
if (!in_array('request', $this->ignoreParams)) {
|
|
$this->ignoreParams[] = 'request';
|
|
}
|
|
|
|
return $this->ignoreParams;
|
|
}
|
|
|
|
}
|