src/Shell/ProfferShell.php
public function generate($table)
    {
        $this->checkTable($table);

        $config = $this->Table->behaviors()->Proffer->config();

        foreach ($config as $field => $settings) {
            $records = $this->{$this->Table->alias()}->find()
                ->select([$this->Table->primaryKey(), $field, $settings['dir']])
                ->where([
                    "$field IS NOT NULL",
                    "$field != ''"
                ]);

            foreach ($records as $item) {
                if ($this->param('verbose')) {
                    $this->out(
                        __('Processing ' . $this->Table->alias() . ' ' . $item->get($this->Table->primaryKey()))
                    );
                }

                if (!empty($this->param('path-class'))) {
                    $class = (string)$this->param('path-class');
                    $path = new $class($this->Table, $item, $field, $settings);
                } else {
                    $path = new ProfferPath($this->Table, $item, $field, $settings);
                }

                if (!empty($this->param('image-class'))) {
                    $class = (string)$this->param('image-class');
                    $transform = new $class($this->Table, $path);
                } else {
                    $transform = new ImageTransform($this->Table, $path);
                }

                $transform->processThumbnails($settings);

                if ($this->param('verbose')) {
                    $this->out(__('Thumbnails regenerated for ' . $path->fullPath()));
                } else {
                    $this->out(__('Thumbnails regenerated for ' . $this->Table->alias() . ' ' . $item->get($field)));
                }
            }
        }

        $this->out($this->nl(0));
        $this->out(__('<info>Completed</info>'));
    }
public function generate($table)
    {
        $this->checkTable($table);

        $config = $this->Table->behaviors()->Proffer->config();

        foreach ($config as $field => $settings) {
            $records = $this->{$this->Table->alias()}->find()
                ->select([$this->Table->primaryKey(), $field, $settings['dir']])
                ->where([
                    "$field IS NOT NULL",
                    "$field != ''"
                ]);

            foreach ($records as $item) {
                if ($this->param('verbose')) {
                    $this->out(
                        __('Processing ' . $this->Table->alias() . ' ' . $item->get($this->Table->primaryKey()))
                    );
                }

                if (!empty($this->param('path-class'))) {
                    $class = (string)$this->param('path-class');
                    $path = new $class($this->Table, $item, $field, $settings);
                } else {
                    $path = new ProfferPath($this->Table, $item, $field, $settings);
                }

                if (!empty($this->param('image-class'))) {
                    $class = (string)$this->param('image-class');
                    $transform = new $class($this->Table, $path);
                } else {
                    $transform = new ImageTransform($this->Table, $path);
                }

                $transform->processThumbnails($settings);

                if ($this->param('verbose')) {
                    $this->out(__('Thumbnails regenerated for ' . $path->fullPath()));
                } else {
                    $this->out(__('Thumbnails regenerated for ' . $this->Table->alias() . ' ' . $item->get($field)));
                }
            }
        }

        $this->out($this->nl(0));
        $this->out(__('<info>Completed</info>'));
    }
public function generate ( $ table ) { $ this -> checkTable ( $ table ) ; $ config = $ this -> Table -> behaviors ( ) -> Proffer -> config ( ) ; foreach ( $ config as $ field => $ settings ) { $ records = $ this -> { $ this -> Table -> alias ( ) } -> find ( ) -> select ( [ $ this -> Table -> primaryKey ( ) , $ field , $ settings [ 'dir' ] ] ) -> where ( [ "$field IS NOT NULL" , "$field != ''" ] ) ; foreach ( $ records as $ item ) { if ( $ this -> param ( 'verbose' ) ) { $ this -> out ( __ ( 'Processing ' . $ this -> Table -> alias ( ) . ' ' . $ item -> get ( $ this -> Table -> primaryKey ( ) ) ) ) ; } if ( ! empty ( $ this -> param ( 'path-class' ) ) ) { $ class = ( string ) $ this -> param ( 'path-class' ) ; $ path = new $ class ( $ this -> Table , $ item , $ field , $ settings ) ; } else { $ path = new ProfferPath ( $ this -> Table , $ item , $ field , $ settings ) ; } if ( ! empty ( $ this -> param ( 'image-class' ) ) ) { $ class = ( string ) $ this -> param ( 'image-class' ) ; $ transform = new $ class ( $ this -> Table , $ path ) ; } else { $ transform = new ImageTransform ( $ this -> Table , $ path ) ; } $ transform -> processThumbnails ( $ settings ) ; if ( $ this -> param ( 'verbose' ) ) { $ this -> out ( __ ( 'Thumbnails regenerated for ' . $ path -> fullPath ( ) ) ) ; } else { $ this -> out ( __ ( 'Thumbnails regenerated for ' . $ this -> Table -> alias ( ) . ' ' . $ item -> get ( $ field ) ) ) ; } } } $ this -> out ( $ this -> nl ( 0 ) ) ; $ this -> out ( __ ( '<info>Completed</info>' ) ) ; }
Load a table, get it's config and then regenerate the thumbnails for that tables upload fields.

@param string $table The name of the table
@return void
Load a table get it s config and then regenerate the thumbnails for that tables upload fields .