public function cmdGenerateAlias()
    {
        $entity = $this->getParam(0);
        $entity_id = $this->getParam(1);
        $all = $this->getParam('all');

        if (empty($entity)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        if (!isset($entity_id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = false;

        if (isset($entity_id)) {

            if (!is_numeric($entity_id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $data = $this->alias->loadEntity($entity, $entity_id);

            if (empty($data)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $alias = $this->alias->generateEntity($entity, $data);

            if (empty($alias)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }

            $result = $this->addAlias($entity, $entity_id, $alias);

        } else if (!empty($all)) {
            $result = $this->generateListAlias($entity);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdGenerateAlias()
    {
        $entity = $this->getParam(0);
        $entity_id = $this->getParam(1);
        $all = $this->getParam('all');

        if (empty($entity)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        if (!isset($entity_id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = false;

        if (isset($entity_id)) {

            if (!is_numeric($entity_id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $data = $this->alias->loadEntity($entity, $entity_id);

            if (empty($data)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $alias = $this->alias->generateEntity($entity, $data);

            if (empty($alias)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }

            $result = $this->addAlias($entity, $entity_id, $alias);

        } else if (!empty($all)) {
            $result = $this->generateListAlias($entity);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdGenerateAlias ( ) { $ entity = $ this -> getParam ( 0 ) ; $ entity_id = $ this -> getParam ( 1 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( empty ( $ entity ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! isset ( $ entity_id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ entity_id ) ) { if ( ! is_numeric ( $ entity_id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ data = $ this -> alias -> loadEntity ( $ entity , $ entity_id ) ; if ( empty ( $ data ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ alias = $ this -> alias -> generateEntity ( $ entity , $ data ) ; if ( empty ( $ alias ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ result = $ this -> addAlias ( $ entity , $ entity_id , $ alias ) ; } else if ( ! empty ( $ all ) ) { $ result = $ this -> generateListAlias ( $ entity ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for "alias-generate" command
Callback for alias - generate command