setUserData() public method

public setUserData ( string $data )
$data string url-encoded string
Example #1
0
 /**
  * Parse the events in an <entry> section
  * @param \DOMElement $entry
  * @param string $currentUserId The current user ID as extracted from the <entry> part
  * @return array(Event)
  */
 protected function extractEvents(\DOMElement $entry, $currentUserId)
 {
     $events = array();
     $domEvents = $entry->getElementsByTagName('event');
     foreach ($domEvents as $domEvent) {
         $event = new Event();
         $event->setType($this->extractEventType($domEvent));
         $date = $this->getDomElement($domEvent, 'eventdate', 'The event date was not found while building the event journal:\\n' . $this->getEventDom($domEvent));
         $event->setUserId($currentUserId);
         // The timestamps in Java contain milliseconds, it's not the case in PHP
         // so we strip millis from the response
         $event->setDate(substr($date->nodeValue, 0, -3));
         $id = $this->getDomElement($domEvent, 'eventidentifier');
         if ($id) {
             $event->setIdentifier($id->nodeValue);
         }
         $href = $this->getDomElement($domEvent, 'href');
         if ($href) {
             $path = str_replace($this->workspaceRootUri, '', $href->nodeValue);
             if (substr($path, -1) === '/') {
                 // Jackrabbit might return paths with trailing slashes. Eliminate them if present.
                 $path = substr($path, 0, -1);
             }
             $event->setPath($path);
         }
         $nodeType = $this->getDomElement($domEvent, 'eventprimarynodetype');
         if ($nodeType) {
             $event->setNodeType($nodeType->nodeValue);
         }
         $userData = $this->getDomElement($domEvent, 'eventuserdata');
         if ($userData) {
             $event->setUserData($userData->nodeValue);
         }
         $eventInfos = $this->getDomElement($domEvent, 'eventinfo');
         if ($eventInfos) {
             foreach ($eventInfos->childNodes as $info) {
                 if ($info->nodeType == XML_ELEMENT_NODE) {
                     $event->addInfo($info->tagName, $info->nodeValue);
                 }
             }
         }
         $events[] = $event;
     }
     return $events;
 }
    public function setUp()
    {
        $this->factory = new Factory();
        $this->transport = $this->getMockBuilder('\\Jackalope\\Transport\\Jackrabbit\\Client')->disableOriginalConstructor()->getMock('fetchEventData');
        $this->session = $this->getSessionMock(array('getNode', 'getNodesByIdentifier'));
        $this->session->expects($this->any())->method('getNode')->will($this->returnValue(null));
        $this->session->expects($this->any())->method('getNodesByIdentifier')->will($this->returnValue(array()));
        $this->filter = new EventFilter($this->factory, $this->session);
        $this->nodeTypeManager = $this->getMockBuilder('Jackalope\\NodeType\\NodeTypeManager')->disableOriginalConstructor()->getMock();
        $this->buffer = new TestBuffer($this->factory, $this->filter, $this->transport, $this->nodeTypeManager, 'http://localhost:8080/server/tests/jcr%3aroot');
        // XML for a single event
        $this->eventXml = <<<EOF
<event xmlns="http://www.day.com/jcr/webdav/1.0">
    <href xmlns="DAV:">http://localhost:8080/server/tests/jcr%3aroot/my_node%5b4%5d/jcr%3aprimaryType</href>
    <eventtype>
        <propertyadded/>
    </eventtype>
    <eventdate>1331652655099</eventdate>
    <eventuserdata>somedifferentdata</eventuserdata>
    <eventprimarynodetype>{http://www.jcp.org/jcr/nt/1.0}unstructured</eventprimarynodetype>
    <eventidentifier>8fe5b853-a657-4ee3-b626-ec3b5407dc13</eventidentifier>
</event>
EOF;
        // XML for event with eventinfo
        $this->eventWithInfoXml = <<<EOX
<event xmlns="http://www.day.com/jcr/webdav/1.0">
    <href
    xmlns="DAV:">http://localhost:8080/server/tests/jcr%3aroot/my_other</href>
    <eventtype>
        <nodemoved/>
    </eventtype>
    <eventdate>1332163767892</eventdate>
    <eventuserdata>somedifferentdata</eventuserdata>
    <eventprimarynodetype>{internal}root</eventprimarynodetype>
    <eventmixinnodetype>{internal}AccessControllable</eventmixinnodetype>
    <eventidentifier>1e80ac75-eff4-4350-bae6-7fae2a84e6f3</eventidentifier>
    <eventinfo>
        <destAbsPath>/my_other</destAbsPath>
        <srcAbsPath>/my_node</srcAbsPath>
    </eventinfo>
</event>
EOX;
        // XML for several events entries
        $this->entryXml = <<<EOF
<entry>
    <title>operations: /my_node[4]</title>
    <id>http://localhost/server/tests?type=journal?type=journal&amp;ts=1360caef7fb-0</id>
    <author>
        <name>system</name>
    </author>
    <updated>2012-03-13T16:30:55.099+01:00</updated>
    <content type="application/vnd.apache.jackrabbit.event+xml">
EOF;
        $this->entryXml .= $this->eventXml . "\n";
        $this->entryXml .= $this->eventXml . "\n";
        // The same event appears twice in this entry
        $this->entryXml .= $this->eventWithInfoXml . "\n";
        $this->entryXml .= '</content></entry>';
        // The object representation of the event defined above
        $this->expectedEvent = new Event($this->factory, $this->nodeTypeManager);
        $this->expectedEvent->setDate('1331652655');
        $this->expectedEvent->setIdentifier('8fe5b853-a657-4ee3-b626-ec3b5407dc13');
        $this->expectedEvent->setPrimaryNodeTypeName('{http://www.jcp.org/jcr/nt/1.0}unstructured');
        $this->expectedEvent->setPath('/my_node%5b4%5d/jcr%3aprimaryType');
        $this->expectedEvent->setType(EventInterface::PROPERTY_ADDED);
        $this->expectedEvent->setUserData('somedifferentdata');
        $this->expectedEvent->setUserId('system');
        $this->expectedEventWithInfo = new Event($this->factory, $this->nodeTypeManager);
        $this->expectedEventWithInfo->setDate('1332163767');
        $this->expectedEventWithInfo->setIdentifier('1e80ac75-eff4-4350-bae6-7fae2a84e6f3');
        $this->expectedEventWithInfo->setPrimaryNodeTypeName('{internal}root');
        $this->expectedEventWithInfo->setMixinNodeTypeNames(array('{internal}AccessControllable'));
        $this->expectedEventWithInfo->setPath('/my_other');
        $this->expectedEventWithInfo->setType(EventInterface::NODE_MOVED);
        $this->expectedEventWithInfo->setUserData('somedifferentdata');
        $this->expectedEventWithInfo->setUserId('system');
        $this->expectedEventWithInfo->addInfo('destAbsPath', '/my_other');
        $this->expectedEventWithInfo->addInfo('srcAbsPath', '/my_node');
    }