public function onLoadCallback(DataContainer $dc)
    {
        if (!$dc->id) {
            return;
        }

        /** @var Input $input */
        $input = $this->framework->getAdapter(Input::class);

        // Handle the edit all modes differently
        if ($input->get('act') === 'editAll' || $input->get('act') === 'overrideAll') {
            $categories = $this->db->fetchColumn('SELECT categories FROM tl_news_archive WHERE limitCategories=1 AND id=?', [$dc->id]);
        } else {
            $categories = $this->db->fetchColumn('SELECT categories FROM tl_news_archive WHERE limitCategories=1 AND id=(SELECT pid FROM tl_news WHERE id=?)', [$dc->id]);
        }

        if (!$categories || 0 === \count($categories = StringUtil::deserialize($categories, true))) {
            return;
        }

        $GLOBALS['TL_DCA'][$dc->table]['fields']['categories']['eval']['rootNodes'] = $categories;
    }
public function onLoadCallback(DataContainer $dc)
    {
        if (!$dc->id) {
            return;
        }

        /** @var Input $input */
        $input = $this->framework->getAdapter(Input::class);

        // Handle the edit all modes differently
        if ($input->get('act') === 'editAll' || $input->get('act') === 'overrideAll') {
            $categories = $this->db->fetchColumn('SELECT categories FROM tl_news_archive WHERE limitCategories=1 AND id=?', [$dc->id]);
        } else {
            $categories = $this->db->fetchColumn('SELECT categories FROM tl_news_archive WHERE limitCategories=1 AND id=(SELECT pid FROM tl_news WHERE id=?)', [$dc->id]);
        }

        if (!$categories || 0 === \count($categories = StringUtil::deserialize($categories, true))) {
            return;
        }

        $GLOBALS['TL_DCA'][$dc->table]['fields']['categories']['eval']['rootNodes'] = $categories;
    }
public function onLoadCallback ( DataContainer $ dc ) { if ( ! $ dc -> id ) { return ; } /** @var Input $input */ $ input = $ this -> framework -> getAdapter ( Input :: class ) ; // Handle the edit all modes differently if ( $ input -> get ( 'act' ) === 'editAll' || $ input -> get ( 'act' ) === 'overrideAll' ) { $ categories = $ this -> db -> fetchColumn ( 'SELECT categories FROM tl_news_archive WHERE limitCategories=1 AND id=?' , [ $ dc -> id ] ) ; } else { $ categories = $ this -> db -> fetchColumn ( 'SELECT categories FROM tl_news_archive WHERE limitCategories=1 AND id=(SELECT pid FROM tl_news WHERE id=?)' , [ $ dc -> id ] ) ; } if ( ! $ categories || 0 === \ count ( $ categories = StringUtil :: deserialize ( $ categories , true ) ) ) { return ; } $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ 'categories' ] [ 'eval' ] [ 'rootNodes' ] = $ categories ; }
On data container load. Limit the categories set in the news archive settings.

@param DataContainer $dc
On data container load . Limit the categories set in the news archive settings .