src/Shell/ProfferShell.php
protected function checkTable($table)
    {
        try {
            $this->Table = $this->loadModel($table);
        } catch (Exception $e) {
            $this->out(__('<error>' . $e->getMessage() . '</error>'));
            $this->_stop();
        }

        if (get_class($this->Table) === 'AppModel') {
            $this->out(__('<error>The table could not be found, instance of AppModel loaded.</error>'));
            $this->_stop();
        }

        if (!$this->Table->hasBehavior('Proffer')) {
            $out = __(
                "<error>The table '" . $this->Table->alias() .
                "' does not have the Proffer behavior attached.</error>"
            );
            $this->out($out);
            $this->_stop();
        }

        $config = $this->Table->behaviors()->Proffer->config();
        foreach ($config as $field => $settings) {
            if (!$this->Table->hasField($field)) {
                $out = __(
                    "<error>The table '" . $this->Table->alias() .
                    "' does not have the configured upload field in it's schema.</error>"
                );
                $this->out($out);
                $this->_stop();
            }
            if (!$this->Table->hasField($settings['dir'])) {
                $out = __(
                    "<error>The table '" . $this->Table->alias() .
                    "' does not have the configured dir field in it's schema.</error>"
                );
                $this->out($out);
                $this->_stop();
            }
        }

        if ($this->param('remove-behaviors')) {
            $removeBehaviors = explode(',', (string)$this->param('remove-behaviors'));
            foreach ($removeBehaviors as $removeBehavior) {
                $this->Table->removeBehavior($removeBehavior);
            }
        }
    }
protected function checkTable($table)
    {
        try {
            $this->Table = $this->loadModel($table);
        } catch (Exception $e) {
            $this->out(__('<error>' . $e->getMessage() . '</error>'));
            $this->_stop();
        }

        if (get_class($this->Table) === 'AppModel') {
            $this->out(__('<error>The table could not be found, instance of AppModel loaded.</error>'));
            $this->_stop();
        }

        if (!$this->Table->hasBehavior('Proffer')) {
            $out = __(
                "<error>The table '" . $this->Table->alias() .
                "' does not have the Proffer behavior attached.</error>"
            );
            $this->out($out);
            $this->_stop();
        }

        $config = $this->Table->behaviors()->Proffer->config();
        foreach ($config as $field => $settings) {
            if (!$this->Table->hasField($field)) {
                $out = __(
                    "<error>The table '" . $this->Table->alias() .
                    "' does not have the configured upload field in it's schema.</error>"
                );
                $this->out($out);
                $this->_stop();
            }
            if (!$this->Table->hasField($settings['dir'])) {
                $out = __(
                    "<error>The table '" . $this->Table->alias() .
                    "' does not have the configured dir field in it's schema.</error>"
                );
                $this->out($out);
                $this->_stop();
            }
        }

        if ($this->param('remove-behaviors')) {
            $removeBehaviors = explode(',', (string)$this->param('remove-behaviors'));
            foreach ($removeBehaviors as $removeBehavior) {
                $this->Table->removeBehavior($removeBehavior);
            }
        }
    }
protected function checkTable ( $ table ) { try { $ this -> Table = $ this -> loadModel ( $ table ) ; } catch ( Exception $ e ) { $ this -> out ( __ ( '<error>' . $ e -> getMessage ( ) . '</error>' ) ) ; $ this -> _stop ( ) ; } if ( get_class ( $ this -> Table ) === 'AppModel' ) { $ this -> out ( __ ( '<error>The table could not be found, instance of AppModel loaded.</error>' ) ) ; $ this -> _stop ( ) ; } if ( ! $ this -> Table -> hasBehavior ( 'Proffer' ) ) { $ out = __ ( "<error>The table '" . $ this -> Table -> alias ( ) . "' does not have the Proffer behavior attached.</error>" ) ; $ this -> out ( $ out ) ; $ this -> _stop ( ) ; } $ config = $ this -> Table -> behaviors ( ) -> Proffer -> config ( ) ; foreach ( $ config as $ field => $ settings ) { if ( ! $ this -> Table -> hasField ( $ field ) ) { $ out = __ ( "<error>The table '" . $ this -> Table -> alias ( ) . "' does not have the configured upload field in it's schema.</error>" ) ; $ this -> out ( $ out ) ; $ this -> _stop ( ) ; } if ( ! $ this -> Table -> hasField ( $ settings [ 'dir' ] ) ) { $ out = __ ( "<error>The table '" . $ this -> Table -> alias ( ) . "' does not have the configured dir field in it's schema.</error>" ) ; $ this -> out ( $ out ) ; $ this -> _stop ( ) ; } } if ( $ this -> param ( 'remove-behaviors' ) ) { $ removeBehaviors = explode ( ',' , ( string ) $ this -> param ( 'remove-behaviors' ) ) ; foreach ( $ removeBehaviors as $ removeBehavior ) { $ this -> Table -> removeBehavior ( $ removeBehavior ) ; } } }
Do some checks on the table which has been passed to make sure that it has what we need

@param string $table The table
@return void
Do some checks on the table which has been passed to make sure that it has what we need