src/Contao/View/Contao2BackendView/Controller/ClipboardController.php
private function checkPermission(ActionEvent $event)
    {
        $actionName = $event->getAction()->getName();

        $environment     = $event->getEnvironment();
        $basicDefinition = $environment->getDataDefinition()->getBasicDefinition();

        if ((('create' === $actionName) && (true === $basicDefinition->isCreatable()))
            || (('cut' === $actionName) && (true === $basicDefinition->isEditable()))
            || (false === \in_array($actionName, ['create', 'cut']))
        ) {
            return true;
        }

        $permissionMessage = 'You have no permission for model ' . $actionName .' ';
        switch ($actionName) {
            case 'create':
                $permissionMessage .= 'in ' . $environment->getDataDefinition()->getName();
                break;

            case 'cut':
                $permissionMessage .= $environment->getInputProvider()->getParameter('source');
                break;

            default:
        }

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">%s.</div>',
                $permissionMessage
            )
        );

        return false;
    }
private function checkPermission(ActionEvent $event)
    {
        $actionName = $event->getAction()->getName();

        $environment     = $event->getEnvironment();
        $basicDefinition = $environment->getDataDefinition()->getBasicDefinition();

        if ((('create' === $actionName) && (true === $basicDefinition->isCreatable()))
            || (('cut' === $actionName) && (true === $basicDefinition->isEditable()))
            || (false === \in_array($actionName, ['create', 'cut']))
        ) {
            return true;
        }

        $permissionMessage = 'You have no permission for model ' . $actionName .' ';
        switch ($actionName) {
            case 'create':
                $permissionMessage .= 'in ' . $environment->getDataDefinition()->getName();
                break;

            case 'cut':
                $permissionMessage .= $environment->getInputProvider()->getParameter('source');
                break;

            default:
        }

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">%s.</div>',
                $permissionMessage
            )
        );

        return false;
    }
private function checkPermission ( ActionEvent $ event ) { $ actionName = $ event -> getAction ( ) -> getName ( ) ; $ environment = $ event -> getEnvironment ( ) ; $ basicDefinition = $ environment -> getDataDefinition ( ) -> getBasicDefinition ( ) ; if ( ( ( 'create' === $ actionName ) && ( true === $ basicDefinition -> isCreatable ( ) ) ) || ( ( 'cut' === $ actionName ) && ( true === $ basicDefinition -> isEditable ( ) ) ) || ( false === \ in_array ( $ actionName , [ 'create' , 'cut' ] ) ) ) { return true ; } $ permissionMessage = 'You have no permission for model ' . $ actionName . ' ' ; switch ( $ actionName ) { case 'create' : $ permissionMessage .= 'in ' . $ environment -> getDataDefinition ( ) -> getName ( ) ; break ; case 'cut' : $ permissionMessage .= $ environment -> getInputProvider ( ) -> getParameter ( 'source' ) ; break ; default : } $ event -> setResponse ( \ sprintf ( '<div style="text-align:center; font-weight:bold; padding:40px;">%s.</div>' , $ permissionMessage ) ) ; return false ; }
Check if permission for action.

@param ActionEvent $event The event.

@return bool
Check if permission for action .