src/Ad/AbstractAdNode.php
protected function buildCreative($type)
    {
        // check type
        $creativeClassName = $this->buildCreativeClassName($type);
        if (!class_exists($creativeClassName)) {
            throw new \Exception('Wrong creative specified: ' . var_export($creativeClassName, true));
        }

        // get container
        if (!$this->creativesDomElement) {
            // get creatives tag
            $this->creativesDomElement = $this->adDomElement->getElementsByTagName('Creatives')->item(0);
            if (!$this->creativesDomElement) {
                $this->creativesDomElement = $this->adDomElement->ownerDocument->createElement('Creatives');
                $this->getDomElement()->appendChild($this->creativesDomElement);
            }
        }

        // Creative dom element: <Creative></Creative>
        $creativeDomElement = $this->creativesDomElement->ownerDocument->createElement('Creative');
        $this->creativesDomElement->appendChild($creativeDomElement);

        // Creative type dom element: <Creative><Linear></Linear></Creative>
        $creativeTypeDomElement = $this->adDomElement->ownerDocument->createElement($type);
        $creativeDomElement->appendChild($creativeTypeDomElement);

        // object
        $creative = new $creativeClassName($creativeDomElement);
        $this->creatives[] = $creative;

        return $creative;
    }
protected function buildCreative($type)
    {
        // check type
        $creativeClassName = $this->buildCreativeClassName($type);
        if (!class_exists($creativeClassName)) {
            throw new \Exception('Wrong creative specified: ' . var_export($creativeClassName, true));
        }

        // get container
        if (!$this->creativesDomElement) {
            // get creatives tag
            $this->creativesDomElement = $this->adDomElement->getElementsByTagName('Creatives')->item(0);
            if (!$this->creativesDomElement) {
                $this->creativesDomElement = $this->adDomElement->ownerDocument->createElement('Creatives');
                $this->getDomElement()->appendChild($this->creativesDomElement);
            }
        }

        // Creative dom element: <Creative></Creative>
        $creativeDomElement = $this->creativesDomElement->ownerDocument->createElement('Creative');
        $this->creativesDomElement->appendChild($creativeDomElement);

        // Creative type dom element: <Creative><Linear></Linear></Creative>
        $creativeTypeDomElement = $this->adDomElement->ownerDocument->createElement($type);
        $creativeDomElement->appendChild($creativeTypeDomElement);

        // object
        $creative = new $creativeClassName($creativeDomElement);
        $this->creatives[] = $creative;

        return $creative;
    }
protected function buildCreative ( $ type ) { // check type $ creativeClassName = $ this -> buildCreativeClassName ( $ type ) ; if ( ! class_exists ( $ creativeClassName ) ) { throw new \ Exception ( 'Wrong creative specified: ' . var_export ( $ creativeClassName , true ) ) ; } // get container if ( ! $ this -> creativesDomElement ) { // get creatives tag $ this -> creativesDomElement = $ this -> adDomElement -> getElementsByTagName ( 'Creatives' ) -> item ( 0 ) ; if ( ! $ this -> creativesDomElement ) { $ this -> creativesDomElement = $ this -> adDomElement -> ownerDocument -> createElement ( 'Creatives' ) ; $ this -> getDomElement ( ) -> appendChild ( $ this -> creativesDomElement ) ; } } // Creative dom element: <Creative></Creative> $ creativeDomElement = $ this -> creativesDomElement -> ownerDocument -> createElement ( 'Creative' ) ; $ this -> creativesDomElement -> appendChild ( $ creativeDomElement ) ; // Creative type dom element: <Creative><Linear></Linear></Creative> $ creativeTypeDomElement = $ this -> adDomElement -> ownerDocument -> createElement ( $ type ) ; $ creativeDomElement -> appendChild ( $ creativeTypeDomElement ) ; // object $ creative = new $ creativeClassName ( $ creativeDomElement ) ; $ this -> creatives [ ] = $ creative ; return $ creative ; }
Create "creative" object of given type

@param string $type

@throws \Exception
@return AbstractLinearCreative
Create creative object of given type