lib/EditableContainer.php
public function define($id, $type)
    {
        $id = (string) $id;

        $this->validateName($id);

        if ($type[0] == ':') {
            $expectedType = substr($type, 1);
            $allowedTypes = (array) $this->getAllowedTypes();
            if (!in_array($expectedType, $allowedTypes)) {
                throw new InvalidArgumentException(sprintf('Cannot use type %s to define item "%s" in %s container. Allowed types are: %s.',
                    $expectedType, $id, $this->name, join(', ', $allowedTypes)));
            }
        } else {
            if (!class_exists($type)) {
                throw new InvalidArgumentException(sprintf('Cannot use non-existing class %s as type to define item "%s" in %s container.',
                    $type, $id, $this->name));
            }
        }

        $this->typemap[$id] = $type;
    }
public function define($id, $type)
    {
        $id = (string) $id;

        $this->validateName($id);

        if ($type[0] == ':') {
            $expectedType = substr($type, 1);
            $allowedTypes = (array) $this->getAllowedTypes();
            if (!in_array($expectedType, $allowedTypes)) {
                throw new InvalidArgumentException(sprintf('Cannot use type %s to define item "%s" in %s container. Allowed types are: %s.',
                    $expectedType, $id, $this->name, join(', ', $allowedTypes)));
            }
        } else {
            if (!class_exists($type)) {
                throw new InvalidArgumentException(sprintf('Cannot use non-existing class %s as type to define item "%s" in %s container.',
                    $type, $id, $this->name));
            }
        }

        $this->typemap[$id] = $type;
    }
public function define ( $ id , $ type ) { $ id = ( string ) $ id ; $ this -> validateName ( $ id ) ; if ( $ type [ 0 ] == ':' ) { $ expectedType = substr ( $ type , 1 ) ; $ allowedTypes = ( array ) $ this -> getAllowedTypes ( ) ; if ( ! in_array ( $ expectedType , $ allowedTypes ) ) { throw new InvalidArgumentException ( sprintf ( 'Cannot use type %s to define item "%s" in %s container. Allowed types are: %s.' , $ expectedType , $ id , $ this -> name , join ( ', ' , $ allowedTypes ) ) ) ; } } else { if ( ! class_exists ( $ type ) ) { throw new InvalidArgumentException ( sprintf ( 'Cannot use non-existing class %s as type to define item "%s" in %s container.' , $ type , $ id , $ this -> name ) ) ; } } $ this -> typemap [ $ id ] = $ type ; }
Defines the given item in the typemap.

@param string $id The name of the item
@param string $type The required type of the value

@throws InvalidArgumentException if the ID name is invalid.
Defines the given item in the typemap .