-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "Argument 1 passed to Mekras\Atom\Extensions::createElement() mus…
…t be an instance of Mekras\Atom\Node, null given" error.
- Loading branch information
Showing
4 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* OData client library | ||
* | ||
* @author Михаил Красильников <m.krasilnikov@yandex.ru> | ||
* @license MIT | ||
*/ | ||
namespace Mekras\OData\Client\Document; | ||
|
||
use Mekras\Atom\Document\EntryDocument as BaseEntryDocument; | ||
use Mekras\Atom\Extensions; | ||
|
||
/** | ||
* OData Service error response. | ||
* | ||
* @since 1.0 | ||
*/ | ||
class EntryDocument extends BaseEntryDocument | ||
{ | ||
/** | ||
* Create document. | ||
* | ||
* @param Extensions $extensions Extension registry. | ||
* @param \DOMDocument|null $document Source document. | ||
* | ||
* @throws \InvalidArgumentException If $document root node has invalid name. | ||
* | ||
* @since 1.0 | ||
*/ | ||
public function __construct(Extensions $extensions, $document = null) | ||
{ | ||
parent::__construct($extensions, $document); | ||
if (null === $document) { | ||
/* For new (empty) entry we should create all necessary nodes. */ | ||
$entry = $this->getEntry(); | ||
$entry->addAuthor(''); | ||
$entry->addContent('', 'text'); | ||
$entry->getProperties(); // Create properties node. | ||
} | ||
} | ||
|
||
/** | ||
* Return entry. | ||
* | ||
* @return \Mekras\OData\Client\Element\Entry | ||
* | ||
* @since 1.0 | ||
*/ | ||
public function getEntry() | ||
{ | ||
// This method is a syntactic sugar. | ||
return parent::getEntry(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters