Last active
September 28, 2015 09:24
-
-
Save manuakasam/aa3894da2575119c81c9 to your computer and use it in GitHub Desktop.
Notice: Undefined property: DrWolff\EventManagement\Entity\MetaData::$metaData in /cbx/htdocs/dw-event-management-website/vendor/dr-wolff/event-management/src/Entity/WithProviderForImmutables.php on line 55 Fatal error: Call to a member function with() on a non-object in /cbx/htdocs/dw-event-management-website/vendor/dr-wolff/event-management/sr…
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
<?php | |
namespace DrWolff\EventManagement\Entity\Seminar; | |
use DrWolff\EventManagement\Entity\MetaData; | |
use DrWolff\EventManagement\Entity\MetaDataProvider; | |
use DrWolff\EventManagement\Entity\WithProviderForImmutables; | |
final class CoreData | |
{ | |
use MetaDataProvider; | |
use WithProviderForImmutables; | |
// | |
// /** | |
// * @param $key | |
// * @param $value | |
// * | |
// * @return CoreData | |
// * @throws InvalidArgumentException | |
// */ | |
// public function with($key, $value) | |
// { | |
// if (false === array_key_exists($key, get_class_vars(self::class))) { | |
// return $this->withMetaData($key, $value); | |
// } | |
// | |
// $new = clone $this; | |
// $new->{$key} = $value; | |
// | |
// if (method_exists($new, "validateArrayObjects")) { | |
// $new->validateArrayObjects(); | |
// } //@codeCoverageIgnore | |
// | |
// return $new; | |
// } | |
// | |
// /** | |
// * @param $key | |
// * @param $value | |
// * | |
// * @return WithProviderForImmutables | |
// */ | |
// private function withMetaData($key, $value) | |
// { | |
// $metaDataFields = ['id', 'createdAt', 'createdBy', 'updatedAt', 'updatedBy', 'isDeleted']; | |
// | |
// if (false === in_array($key, $metaDataFields)) { | |
// throw new \InvalidArgumentException( | |
// sprintf( | |
// 'Invalid key called. Key %s does not exist in class %s', | |
// $key, | |
// self::class | |
// ) | |
// ); | |
// } | |
// | |
// $new = clone $this; | |
// $new->metaData = $new->metaData->with($key, $value); | |
// | |
// return $new; | |
// } | |
/** | |
* @var string | |
*/ | |
private $title; | |
/** | |
* @var string | |
*/ | |
private $description; | |
/** | |
* @var array | |
*/ | |
private $timeTable; | |
/** | |
* @var array | |
*/ | |
private $trainerResources; | |
/** | |
* @var array | |
*/ | |
private $requiredQualifications; | |
/** | |
* @var array | |
*/ | |
private $providedQualifications; | |
/** | |
* @var string | |
*/ | |
private $certificateTemplate; | |
/** | |
* @var int | |
*/ | |
private $minAttendees; | |
/** | |
* @var int | |
*/ | |
private $maxAttendees; | |
/** | |
* @var int | |
*/ | |
private $pricePerAttendee; | |
/** | |
* @var array | |
*/ | |
private $cancellationRules; | |
/** | |
* @var array | |
*/ | |
private $rites; | |
/** | |
* @var bool | |
*/ | |
private $requiresLaptop; | |
/** | |
* @var bool | |
*/ | |
private $requiresModel; | |
/** | |
* @var bool | |
*/ | |
private $requiresTrainerMissionReport; | |
/** | |
* @var bool | |
*/ | |
private $requiresShop; | |
/** | |
* @var bool | |
*/ | |
private $requiresWifi; | |
/** | |
* @var array | |
*/ | |
private $media; | |
/** | |
* @var array | |
*/ | |
private $material; | |
/** | |
* CoreData constructor. | |
* | |
* @param string $title | |
* @param string $description | |
* @param array $timeTable | |
* @param array $trainerResources | |
* @param array $requiredQualifications | |
* @param array $providedQualifications | |
* @param string $certificateTemplate | |
* @param int $minAttendees | |
* @param int $maxAttendees | |
* @param int $pricePerAttendee | |
* @param array $cancellationRules | |
* @param array $rites | |
* @param bool $requiresLaptop | |
* @param bool $requiresModel | |
* @param bool $requiresTrainerMissionReport | |
* @param bool $requiresShop | |
* @param bool $requiresWifi | |
* @param array $media | |
* @param array $material | |
* @param MetaData $metaData | |
*/ | |
public function __construct( | |
$title, | |
$description, | |
array $timeTable, | |
array $trainerResources, | |
array $requiredQualifications, | |
array $providedQualifications, | |
$certificateTemplate, | |
$minAttendees, | |
$maxAttendees, | |
$pricePerAttendee, | |
array $cancellationRules, | |
array $rites, | |
$requiresLaptop, | |
$requiresModel, | |
$requiresTrainerMissionReport, | |
$requiresShop, | |
$requiresWifi, | |
array $media, | |
array $material, | |
MetaData $metaData | |
) { | |
$this->title = $title; | |
$this->description = $description; | |
$this->timeTable = $timeTable; | |
$this->trainerResources = $trainerResources; | |
$this->requiredQualifications = $requiredQualifications; | |
$this->providedQualifications = $providedQualifications; | |
$this->certificateTemplate = $certificateTemplate; | |
$this->minAttendees = $minAttendees; | |
$this->maxAttendees = $maxAttendees; | |
$this->pricePerAttendee = $pricePerAttendee; | |
$this->cancellationRules = $cancellationRules; | |
$this->rites = $rites; | |
$this->requiresLaptop = $requiresLaptop; | |
$this->requiresModel = $requiresModel; | |
$this->requiresTrainerMissionReport = $requiresTrainerMissionReport; | |
$this->requiresShop = $requiresShop; | |
$this->requiresWifi = $requiresWifi; | |
$this->media = $media; | |
$this->material = $material; | |
$this->metaData = $metaData; | |
} | |
/** | |
* @return string | |
*/ | |
public function getTitle() | |
{ | |
return $this->title; | |
} | |
/** | |
* @return string | |
*/ | |
public function getDescription() | |
{ | |
return $this->description; | |
} | |
/** | |
* @return array | |
*/ | |
public function getTimeTable() | |
{ | |
return $this->timeTable; | |
} | |
/** | |
* @return array | |
*/ | |
public function getTrainerResources() | |
{ | |
return $this->trainerResources; | |
} | |
/** | |
* @return array | |
*/ | |
public function getRequiredQualifications() | |
{ | |
return $this->requiredQualifications; | |
} | |
/** | |
* @return array | |
*/ | |
public function getProvidedQualifications() | |
{ | |
return $this->providedQualifications; | |
} | |
/** | |
* @return string | |
*/ | |
public function getCertificateTemplate() | |
{ | |
return $this->certificateTemplate; | |
} | |
/** | |
* @return float | |
*/ | |
public function getPricePerAttendee() | |
{ | |
return $this->pricePerAttendee; | |
} | |
/** | |
* @return array | |
*/ | |
public function getCancellationRules() | |
{ | |
return $this->cancellationRules; | |
} | |
/** | |
* @return array | |
*/ | |
public function getRites() | |
{ | |
return $this->rites; | |
} | |
/** | |
* @return int | |
*/ | |
public function getMinAttendees() | |
{ | |
return $this->minAttendees; | |
} | |
/** | |
* @return int | |
*/ | |
public function getMaxAttendees() | |
{ | |
return $this->maxAttendees; | |
} | |
/** | |
* @return bool | |
*/ | |
public function requiresLaptop() | |
{ | |
return $this->requiresLaptop; | |
} | |
/** | |
* @return bool | |
*/ | |
public function requiresModel() | |
{ | |
return $this->requiresModel; | |
} | |
/** | |
* @return bool | |
*/ | |
public function requiresTrainerMissionReport() | |
{ | |
return $this->requiresTrainerMissionReport; | |
} | |
/** | |
* @return bool | |
*/ | |
public function requiresShop() | |
{ | |
return $this->requiresShop; | |
} | |
/** | |
* @return bool | |
*/ | |
public function requiresWifi() | |
{ | |
return $this->requiresWifi; | |
} | |
/** | |
* @return array | |
*/ | |
public function getMedia() | |
{ | |
return $this->media; | |
} | |
/** | |
* @return array | |
*/ | |
public function getMaterial() | |
{ | |
return $this->material; | |
} | |
} |
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
<?php | |
/** | |
* @author Manuel Stosic <[email protected]> | |
*/ | |
namespace SeminarPlanner\Controller; | |
use DrWolff\EventManagement\Service\CoreData\WriteService; | |
use Zend\Form\FormInterface; | |
use Zend\Http\PhpEnvironment\Response; | |
use Zend\Mvc\Controller\AbstractActionController; | |
use Zend\View\Model\ViewModel; | |
final class CoreDataAddController extends AbstractActionController | |
{ | |
/** | |
* @var FormInterface | |
*/ | |
private $addForm; | |
/** | |
* @var WriteService | |
*/ | |
private $writeService; | |
/** | |
* @param FormInterface $addForm | |
* @param WriteService $writeService | |
*/ | |
public function __construct( | |
FormInterface $addForm, | |
WriteService $writeService | |
) { | |
$this->addForm = $addForm; | |
$this->writeService = $writeService; | |
} | |
public function addAction() | |
{ | |
$prg = $this->prg('seminar/core-data/add'); | |
if ($prg instanceof Response) { | |
return $prg; | |
} | |
$vm = new ViewModel(); | |
$vm->setTemplate('seminar-planner/core-data/add'); | |
if ($prg === false) { | |
return $vm->setVariables([ | |
'form' => $this->addForm | |
]); | |
} | |
$this->addForm->setData($prg); | |
if (false === $this->addForm->isValid()) { | |
return $vm->setVariables([ | |
'form' => $this->addForm | |
]); | |
} | |
$coreDataObject = $this->addForm->getData(); | |
/** | |
* Notice: Undefined property: DrWolff\EventManagement\Entity\MetaData::$metaData in /cbx/htdocs/dw-event-management-website/vendor/dr-wolff/event-management/src/Entity/WithProviderForImmutables.php on line 55 | |
* | |
* Fatal error: Call to a member function with() on a non-object in /cbx/htdocs/dw-event-management-website/vendor/dr-wolff/event-management/src/Entity/WithProviderForImmutables.php on line 55 | |
* | |
* | |
*/ | |
var_dump($coreDataObject); | |
die(); | |
return $vm->setVariables([ | |
'form' => $this->addForm | |
]); | |
} | |
} |
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
<?php | |
/** | |
* @author Manuel Stosic <[email protected]> | |
*/ | |
namespace SeminarPlanner\Form; | |
use DateTimeImmutable; | |
use DrWolff\EventManagement\Entity\MetaData; | |
use DrWolff\EventManagement\Entity\Seminar\CoreData; | |
use DrWolff\EventManagement\Hydrator\Seminar\CoreDataHydrator; | |
use Zend\Form\Element\Hidden; | |
use Zend\Form\Element\Text; | |
use Zend\Form\Element\Textarea; | |
use Zend\Form\Fieldset; | |
final class CoreDataFieldset extends Fieldset | |
{ | |
public function __construct($name = 'core-data-fieldset', $options = []) | |
{ | |
parent::__construct($name, $options); | |
} | |
public function init() | |
{ | |
$this->setHydrator(new CoreDataHydrator()); | |
$this->setObject(new CoreData( | |
'', | |
'', | |
[], | |
[], | |
[], | |
[], | |
'', | |
0, | |
0, | |
0, | |
[], | |
[], | |
false, | |
false, | |
false, | |
false, | |
false, | |
[], | |
[], | |
new MetaData('', new DateTimeImmutable(), null, null) | |
)); | |
$this->add([ | |
'name' => 'id', | |
'type' => Hidden::class | |
]); | |
$this->add([ | |
'name' => 'title', | |
'type' => Text::class, | |
'options' => [ | |
'label' => 'Titel' | |
] | |
]); | |
$this->add([ | |
'name' => 'description', | |
'type' => Textarea::class, | |
'options' => [ | |
'label' => 'Beschreibung' | |
] | |
]); | |
} | |
} |
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
<?php | |
/** | |
* @author Manuel Stosic <[email protected]> | |
*/ | |
namespace SeminarPlanner\Form; | |
use Zend\Form\Element\Csrf; | |
use Zend\Form\Element\Submit; | |
use Zend\Form\Form; | |
final class CoreDataAddForm extends Form | |
{ | |
public function __construct($options = []) | |
{ | |
parent::__construct('core-data-add-form', $options); | |
} | |
public function init() | |
{ | |
$this->add([ | |
'name' => 'csrf', | |
'type' => Csrf::class | |
]); | |
$this->add([ | |
'name' => 'core-data-fieldset', | |
'type' => CoreDataFieldset::class, | |
'options' => [ | |
'use_as_base_fieldset' => true | |
] | |
]); | |
$this->add([ | |
'name' => 'submit', | |
'type' => Submit::class, | |
'attributes' => [ | |
'value' => 'Stammdaten speichern', | |
'class' => 'btn btn-success' | |
] | |
]); | |
} | |
} |
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
<?php | |
/** | |
* @author Manuel Stosic <[email protected]> | |
*/ | |
namespace DrWolff\EventManagement\Hydrator\Seminar; | |
use DrWolff\EventManagement\Entity\Seminar\CoreData; | |
use Zend\Stdlib\Hydrator\HydratorInterface; | |
final class CoreDataHydrator implements HydratorInterface | |
{ | |
/** | |
* Hydrate $object with the provided $data. | |
* | |
* @param array $data | |
* @param object $object | |
* @return object | |
*/ | |
public function hydrate(array $data, $object) | |
{ | |
foreach ($data as $key => $value) { | |
$object = $object->with($key, $value); | |
} | |
return $object; | |
} | |
/** | |
* Extract values from an object | |
* | |
* @param CoreData $object | |
* @return array | |
*/ | |
public function extract($object) | |
{ | |
return [ | |
'id' => $object->getId(), | |
'title' => $object->getTitle(), | |
'description' => $object->getDescription(), | |
'timeTable' => $object->getTimeTable(), | |
'trainerResources' => $object->getTrainerResources(), | |
'requiredQualifications' => $object->getRequiredQualifications(), | |
'providedQualifications' => $object->getProvidedQualifications(), | |
'certificateTemplate' => $object->getCertificateTemplate(), | |
'minAttendees' => $object->getMinAttendees(), | |
'maxAttendees' => $object->getMaxAttendees(), | |
'pricePerAttendee' => $object->getPricePerAttendee(), | |
'cancellationRules' => $object->getCancellationRules(), | |
'rites' => $object->getRites(), | |
'requiresLaptop' => $object->requiresLaptop(), | |
'requiresModel' => $object->requiresModel(), | |
'requiresTrainerMissionReport' => $object->requiresTrainerMissionReport(), | |
'requiresShop' => $object->requiresShop(), | |
'requiresWifi' => $object->requiresWifi(), | |
'media' => $object->getMedia(), | |
'material' => $object->getMaterial() | |
]; | |
} | |
} |
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
<?php | |
namespace DrWolff\EventManagement\Entity; | |
use DateTimeImmutable; | |
/** | |
* If you add things here, please update WithProviderForImmutables, to | |
* reflect the change | |
* | |
* @see WithProviderForImmutables | |
* | |
* Class MetaData | |
* @package DrWolff\EventManagement\Entity | |
*/ | |
final class MetaData | |
{ | |
use WithProviderForImmutables; | |
/** | |
* @var string | |
*/ | |
private $createdBy; | |
/** | |
* @var DateTimeImmutable | |
*/ | |
private $createdAt; | |
/** | |
* @var null | |
*/ | |
private $updatedBy; | |
/** | |
* @var DateTimeImmutable | |
*/ | |
private $updatedAt; | |
/** | |
* @var null | |
*/ | |
private $id; | |
/** | |
* @var bool | |
*/ | |
private $isDeleted; | |
/** | |
* MetaData constructor. | |
* | |
* @param string $createdBy | |
* @param DateTimeImmutable $createdAt | |
* @param string $updatedBy | |
* @param DateTimeImmutable|null $updatedAt | |
* @param int $id | |
* @param bool|false $isDeleted | |
*/ | |
public function __construct( | |
$createdBy, | |
DateTimeImmutable $createdAt, | |
$updatedBy = null, | |
DateTimeImmutable $updatedAt = null, | |
$id = null, | |
$isDeleted = false | |
) { | |
$this->createdBy = $createdBy; | |
$this->createdAt = $createdAt; | |
$this->updatedBy = $updatedBy; | |
$this->updatedAt = $updatedAt; | |
$this->id = $id; | |
$this->isDeleted = $isDeleted; | |
} | |
/** | |
* @return string | |
*/ | |
public function getCreatedBy() | |
{ | |
return $this->createdBy; | |
} | |
/** | |
* @return DateTimeImmutable | |
*/ | |
public function getCreatedAt() | |
{ | |
return $this->createdAt; | |
} | |
/** | |
* @return null | |
*/ | |
public function getUpdatedBy() | |
{ | |
return $this->updatedBy; | |
} | |
/** | |
* @return DateTimeImmutable | |
*/ | |
public function getUpdatedAt() | |
{ | |
return $this->updatedAt; | |
} | |
/** | |
* @return null | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* @return boolean | |
*/ | |
public function isDeleted() | |
{ | |
return $this->isDeleted; | |
} | |
} |
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
<?php | |
/** | |
* @author Manuel Stosic <[email protected]> | |
*/ | |
namespace DrWolff\EventManagement\Entity; | |
use DateTimeImmutable; | |
trait MetaDataProvider | |
{ | |
/** | |
* @var MetaData | |
*/ | |
private $metaData; | |
/** | |
* @return string | |
*/ | |
public function getCreatedBy() | |
{ | |
return $this->metaData->getCreatedBy(); | |
} | |
/** | |
* @return DateTimeImmutable | |
*/ | |
public function getCreatedAt() | |
{ | |
return $this->metaData->getCreatedAt(); | |
} | |
/** | |
* @return null|string | |
*/ | |
public function getUpdatedBy() | |
{ | |
return $this->metaData->getUpdatedBy(); | |
} | |
/** | |
* @return DateTimeImmutable|null | |
*/ | |
public function getUpdatedAt() | |
{ | |
return $this->metaData->getUpdatedAt(); | |
} | |
/** | |
* @return int|null | |
*/ | |
public function getId() | |
{ | |
return $this->metaData->getId(); | |
} | |
/** | |
* @return boolean | |
*/ | |
public function isDeleted() | |
{ | |
return $this->metaData->isDeleted(); | |
} | |
} |
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
<?php | |
namespace DrWolff\EventManagement\Entity; | |
use DrWolff\EventManagement\Entity\Seminar\CoreData; | |
use InvalidArgumentException; | |
trait WithProviderForImmutables | |
{ | |
/** | |
* @param $key | |
* @param $value | |
* | |
* @return CoreData | |
* @throws InvalidArgumentException | |
*/ | |
public function with($key, $value) | |
{ | |
if (false === array_key_exists($key, get_class_vars(self::class))) { | |
return $this->withMetaData($key, $value); | |
} | |
$new = clone $this; | |
$new->{$key} = $value; | |
if (method_exists($new, "validateArrayObjects")) { | |
$new->validateArrayObjects(); | |
} //@codeCoverageIgnore | |
return $new; | |
} | |
/** | |
* @param $key | |
* @param $value | |
* | |
* @return WithProviderForImmutables | |
*/ | |
private function withMetaData($key, $value) | |
{ | |
$metaDataFields = ['id', 'createdAt', 'createdBy', 'updatedAt', 'updatedBy', 'isDeleted']; | |
if (false === in_array($key, $metaDataFields)) { | |
throw new InvalidArgumentException( | |
sprintf( | |
'Invalid key called. Key %s does not exist in class %s', | |
$key, | |
static::class | |
) | |
); | |
} | |
$new = clone $this; | |
$new->metaData = $new->metaData->with($key, $value); | |
return $new; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment