forked from pimcore/pimcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added before load event for objects, documents and assets
- Loading branch information
Showing
9 changed files
with
220 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Event\Model; | ||
|
||
use Pimcore\Event\Traits\ArgumentsAwareTrait; | ||
use Pimcore\Model\Asset; | ||
use Pimcore\Model\Exception\NotFoundException; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
class AssetPreLoadEvent extends Event implements ElementEventInterface | ||
{ | ||
use ArgumentsAwareTrait; | ||
|
||
protected ?Asset $asset; | ||
|
||
/** | ||
* AssetEvent constructor. | ||
* | ||
* @param array $arguments additional parameters (e.g. "versionNote" for the version note) | ||
*/ | ||
public function __construct(?Asset $asset, array $arguments = []) | ||
{ | ||
$this->asset = $asset; | ||
$this->arguments = $arguments; | ||
} | ||
|
||
public function getAsset(): ?Asset | ||
{ | ||
if (empty($this->document)) { | ||
throw new NotFoundException(); | ||
} | ||
return $this->asset; | ||
} | ||
|
||
public function setAsset(?Asset $asset): void | ||
{ | ||
$this->asset = $asset; | ||
} | ||
|
||
public function getElement(): Asset | ||
{ | ||
return $this->getAsset(); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Event\Model; | ||
|
||
use Pimcore\Event\Traits\ArgumentsAwareTrait; | ||
use Pimcore\Model\DataObject\AbstractObject; | ||
use Pimcore\Model\Exception\NotFoundException; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
class DataObjectPreLoadEvent extends Event implements ElementEventInterface | ||
{ | ||
use ArgumentsAwareTrait; | ||
|
||
protected ?AbstractObject $object; | ||
|
||
/** | ||
* DataObjectEvent constructor. | ||
* | ||
*/ | ||
public function __construct(?AbstractObject $object, array $arguments = []) | ||
{ | ||
$this->object = $object; | ||
$this->arguments = $arguments; | ||
} | ||
|
||
public function getObject(): ?AbstractObject | ||
{ | ||
if (empty($this->object)) { | ||
throw new NotFoundException(); | ||
} | ||
return $this->object; | ||
} | ||
|
||
public function setObject(?AbstractObject $object): void | ||
{ | ||
$this->object = $object; | ||
} | ||
|
||
public function getElement(): AbstractObject | ||
{ | ||
return $this->getObject(); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Event\Model; | ||
|
||
use Pimcore\Event\Traits\ArgumentsAwareTrait; | ||
use Pimcore\Model\Document; | ||
use Pimcore\Model\Exception\NotFoundException; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
class DocumentPreLoadEvent extends Event implements ElementEventInterface | ||
{ | ||
use ArgumentsAwareTrait; | ||
|
||
protected ?Document $document; | ||
|
||
/** | ||
* DocumentEvent constructor. | ||
* | ||
*/ | ||
public function __construct(?Document $document, array $arguments = []) | ||
{ | ||
$this->document = $document; | ||
$this->arguments = $arguments; | ||
} | ||
|
||
public function getDocument(): ?Document | ||
{ | ||
if (empty($this->document)) { | ||
throw new NotFoundException(); | ||
} | ||
return $this->document; | ||
} | ||
|
||
public function setDocument(?Document $document): void | ||
{ | ||
$this->document = $document; | ||
} | ||
|
||
public function getElement(): Document | ||
{ | ||
return $this->getDocument(); | ||
} | ||
} |
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