public function handle(BuildMetaModelOperationsEvent $event)
    {
        if (!$this->scopeMatcher->currentScopeIsBackend()) {
            return;
        }
        $allProps   = $event->getScreen()['properties'];
        $properties = \array_map(function ($property) {
            return ($property['col_name'] ?? null);
        }, $allProps);
        foreach ($event->getMetaModel()->getAttributes() as $attribute) {
            if (!$this->wantToAdd($attribute, $properties)) {
                continue;
            }
            $info = [];
            foreach ($allProps as $prop) {
                if ($prop['col_name'] === $attribute->getColName()) {
                    $info = $prop;
                }
            }

            $toggle    = $this->buildCommand($attribute, $info);
            $container = $event->getContainer();
            $view      = $this->createBackendViewDefinition($container);

            $commands = $view->getModelCommands();

            if (!$commands->hasCommandNamed($toggle->getName())) {
                if ($commands->hasCommandNamed('show')) {
                    $info = $commands->getCommandNamed('show');
                } else {
                    $info = null;
                }
                $commands->addCommand($toggle, $info);
            }
        }
    }
public function handle(BuildMetaModelOperationsEvent $event)
    {
        if (!$this->scopeMatcher->currentScopeIsBackend()) {
            return;
        }
        $allProps   = $event->getScreen()['properties'];
        $properties = \array_map(function ($property) {
            return ($property['col_name'] ?? null);
        }, $allProps);
        foreach ($event->getMetaModel()->getAttributes() as $attribute) {
            if (!$this->wantToAdd($attribute, $properties)) {
                continue;
            }
            $info = [];
            foreach ($allProps as $prop) {
                if ($prop['col_name'] === $attribute->getColName()) {
                    $info = $prop;
                }
            }

            $toggle    = $this->buildCommand($attribute, $info);
            $container = $event->getContainer();
            $view      = $this->createBackendViewDefinition($container);

            $commands = $view->getModelCommands();

            if (!$commands->hasCommandNamed($toggle->getName())) {
                if ($commands->hasCommandNamed('show')) {
                    $info = $commands->getCommandNamed('show');
                } else {
                    $info = null;
                }
                $commands->addCommand($toggle, $info);
            }
        }
    }
public function handle ( BuildMetaModelOperationsEvent $ event ) { if ( ! $ this -> scopeMatcher -> currentScopeIsBackend ( ) ) { return ; } $ allProps = $ event -> getScreen ( ) [ 'properties' ] ; $ properties = \ array_map ( function ( $ property ) { return ( $ property [ 'col_name' ] ?? null ) ; } , $ allProps ) ; foreach ( $ event -> getMetaModel ( ) -> getAttributes ( ) as $ attribute ) { if ( ! $ this -> wantToAdd ( $ attribute , $ properties ) ) { continue ; } $ info = [ ] ; foreach ( $ allProps as $ prop ) { if ( $ prop [ 'col_name' ] === $ attribute -> getColName ( ) ) { $ info = $ prop ; } } $ toggle = $ this -> buildCommand ( $ attribute , $ info ) ; $ container = $ event -> getContainer ( ) ; $ view = $ this -> createBackendViewDefinition ( $ container ) ; $ commands = $ view -> getModelCommands ( ) ; if ( ! $ commands -> hasCommandNamed ( $ toggle -> getName ( ) ) ) { if ( $ commands -> hasCommandNamed ( 'show' ) ) { $ info = $ commands -> getCommandNamed ( 'show' ) ; } else { $ info = null ; } $ commands -> addCommand ( $ toggle , $ info ) ; } } }
Create the property conditions.

@param BuildMetaModelOperationsEvent $event The event.

@return void

@throws \RuntimeException When no MetaModel is attached to the event or any other important information could
not be retrieved.
Create the property conditions .