src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php
protected function resolveRelatedModel($pattern)
    {
        list($class, $prop) = array_pad($this->parseAsArray($pattern, ':'), 2, null);
        $model = $this->modelFactory()->get($class);

        if (!$prop) {
            throw new InvalidArgumentException(
                sprintf(
                    'The related model [%s] requires a target property',
                    get_class($model)
                )
            );
        }

        $metadata = $model->metadata();
        if (!$metadata->property($prop)) {
            throw new InvalidArgumentException(
                sprintf(
                    'The related model [%1$s] does not have the target property [%2$s]',
                    $class,
                    (is_string($prop) ? $prop : gettype($prop))
                )
            );
        }

        return [$model, $prop];
    }
protected function resolveRelatedModel($pattern)
    {
        list($class, $prop) = array_pad($this->parseAsArray($pattern, ':'), 2, null);
        $model = $this->modelFactory()->get($class);

        if (!$prop) {
            throw new InvalidArgumentException(
                sprintf(
                    'The related model [%s] requires a target property',
                    get_class($model)
                )
            );
        }

        $metadata = $model->metadata();
        if (!$metadata->property($prop)) {
            throw new InvalidArgumentException(
                sprintf(
                    'The related model [%1$s] does not have the target property [%2$s]',
                    $class,
                    (is_string($prop) ? $prop : gettype($prop))
                )
            );
        }

        return [$model, $prop];
    }
protected function resolveRelatedModel ( $ pattern ) { list ( $ class , $ prop ) = array_pad ( $ this -> parseAsArray ( $ pattern , ':' ) , 2 , null ) ; $ model = $ this -> modelFactory ( ) -> get ( $ class ) ; if ( ! $ prop ) { throw new InvalidArgumentException ( sprintf ( 'The related model [%s] requires a target property' , get_class ( $ model ) ) ) ; } $ metadata = $ model -> metadata ( ) ; if ( ! $ metadata -> property ( $ prop ) ) { throw new InvalidArgumentException ( sprintf ( 'The related model [%1$s] does not have the target property [%2$s]' , $ class , ( is_string ( $ prop ) ? $ prop : gettype ( $ prop ) ) ) ) ; } return [ $ model , $ prop ] ; }
Resolve the given related model.

@param  string $pattern A 'model:property' identifier.
@throws InvalidArgumentException If the identifier is invalid.
@return array Returns an array containing a ModelInterface and a property identifier.
Resolve the given related model .