public static function factory(Localization $base, Block $source = null)
	{
		$block = null;

		switch ($base::DISCRIMINATOR) {
			case self::TEMPLATE_DISCR:
				$block = new TemplateBlock();
				break;
			case self::PAGE_DISCR:
			case self::APPLICATION_DISCR:
				$block = new PageBlock();
				break;
			default:
				throw new \LogicException("Not recognized discriminator value for entity [{$base}].");
		}

		if ($source !== null) {
			$block->setComponentClass($source->getComponentClass());
			$block->setPosition($source->getPosition());

			foreach ($source->getBlockProperties() as $blockProperty) {
				/* @var $blockProperty BlockProperty */

				$newBlockProperty = clone $blockProperty;

				$newBlockProperty->setLocalization($base);
				$newBlockProperty->setBlock($block);

				$block->getBlockProperties()
						->add($newBlockProperty);
			}
		}

		return $block;
	}
public static function factory(Localization $base, Block $source = null)
	{
		$block = null;

		switch ($base::DISCRIMINATOR) {
			case self::TEMPLATE_DISCR:
				$block = new TemplateBlock();
				break;
			case self::PAGE_DISCR:
			case self::APPLICATION_DISCR:
				$block = new PageBlock();
				break;
			default:
				throw new \LogicException("Not recognized discriminator value for entity [{$base}].");
		}

		if ($source !== null) {
			$block->setComponentClass($source->getComponentClass());
			$block->setPosition($source->getPosition());

			foreach ($source->getBlockProperties() as $blockProperty) {
				/* @var $blockProperty BlockProperty */

				$newBlockProperty = clone $blockProperty;

				$newBlockProperty->setLocalization($base);
				$newBlockProperty->setBlock($block);

				$block->getBlockProperties()
						->add($newBlockProperty);
			}
		}

		return $block;
	}
public static function factory ( Localization $ base , Block $ source = null ) { $ block = null ; switch ( $ base :: DISCRIMINATOR ) { case self :: TEMPLATE_DISCR : $ block = new TemplateBlock ( ) ; break ; case self :: PAGE_DISCR : case self :: APPLICATION_DISCR : $ block = new PageBlock ( ) ; break ; default : throw new \ LogicException ( "Not recognized discriminator value for entity [{$base}]." ) ; } if ( $ source !== null ) { $ block -> setComponentClass ( $ source -> getComponentClass ( ) ) ; $ block -> setPosition ( $ source -> getPosition ( ) ) ; foreach ( $ source -> getBlockProperties ( ) as $ blockProperty ) { /* @var $blockProperty BlockProperty */ $ newBlockProperty = clone $ blockProperty ; $ newBlockProperty -> setLocalization ( $ base ) ; $ newBlockProperty -> setBlock ( $ block ) ; $ block -> getBlockProperties ( ) -> add ( $ newBlockProperty ) ; } } return $ block ; }
Creates new instance based on the discriminator of the base entity.

@param Localization $base
@return Block
Creates new instance based on the discriminator of the base entity .