public function setDefaultType($value, $dc)
	{
		if (!$value)
		{
			if ($dc->activeRecord !== null)
			{
				$ptable =  $dc->activeRecord->ptable;
				$pid = $dc->activeRecord->pid;
			}
			else
			{
				return $value;
			}
			
			// Try to find content block elements for the theme
			$objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid));	
			$objDefault = \ElementsModel::findDefaultPublishedElementByPid($objLayout->pid);
			
			// if no default content element is found 
			if ($objDefault === null)
			{
				if (\Config::get('hideLegacyCTE'))
				{
					$objDefault = \ElementsModel::findFirstPublishedElementByPid($objLayout->pid);
				}
				
				if ($objDefault === null)
				{
					$objDefault = new \stdClass();
					$objDefault->alias = 'text';
				}
			}

			$objContent = \ContentModel::findByPk($dc->id);

			$objContent->type = $objDefault->alias;
			$objContent->save();
				
			$this->redirect(\Environment::get('request'));
		}
	
		return $value;
	}
public function setDefaultType($value, $dc)
	{
		if (!$value)
		{
			if ($dc->activeRecord !== null)
			{
				$ptable =  $dc->activeRecord->ptable;
				$pid = $dc->activeRecord->pid;
			}
			else
			{
				return $value;
			}
			
			// Try to find content block elements for the theme
			$objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid));	
			$objDefault = \ElementsModel::findDefaultPublishedElementByPid($objLayout->pid);
			
			// if no default content element is found 
			if ($objDefault === null)
			{
				if (\Config::get('hideLegacyCTE'))
				{
					$objDefault = \ElementsModel::findFirstPublishedElementByPid($objLayout->pid);
				}
				
				if ($objDefault === null)
				{
					$objDefault = new \stdClass();
					$objDefault->alias = 'text';
				}
			}

			$objContent = \ContentModel::findByPk($dc->id);

			$objContent->type = $objDefault->alias;
			$objContent->save();
				
			$this->redirect(\Environment::get('request'));
		}
	
		return $value;
	}
public function setDefaultType ( $ value , $ dc ) { if ( ! $ value ) { if ( $ dc -> activeRecord !== null ) { $ ptable = $ dc -> activeRecord -> ptable ; $ pid = $ dc -> activeRecord -> pid ; } else { return $ value ; } // Try to find content block elements for the theme $ objLayout = \ LayoutModel :: findById ( \ Agoat \ CustomContentElementsBundle \ Contao \ Controller :: getLayoutId ( $ ptable , $ pid ) ) ; $ objDefault = \ ElementsModel :: findDefaultPublishedElementByPid ( $ objLayout -> pid ) ; // if no default content element is found  if ( $ objDefault === null ) { if ( \ Config :: get ( 'hideLegacyCTE' ) ) { $ objDefault = \ ElementsModel :: findFirstPublishedElementByPid ( $ objLayout -> pid ) ; } if ( $ objDefault === null ) { $ objDefault = new \ stdClass ( ) ; $ objDefault -> alias = 'text' ; } } $ objContent = \ ContentModel :: findByPk ( $ dc -> id ) ; $ objContent -> type = $ objDefault -> alias ; $ objContent -> save ( ) ; $ this -> redirect ( \ Environment :: get ( 'request' ) ) ; } return $ value ; }
Set default value for new records

@param mixed         @value
@param DataContainer $dc

@return mixed
Set default value for new records