add isObject check
This commit is contained in:
parent
ea9002dff1
commit
aae408c264
16
CHANGELOG.md
16
CHANGELOG.md
@ -4,7 +4,21 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased](https://git.d3data.de/D3Public/oxid_twig_extensions/compare/1.0.0.0...rel_1.x)
|
## [Unreleased](https://git.d3data.de/D3Public/oxid_twig_extensions/compare/1.3.0.0...rel_1.x)
|
||||||
|
|
||||||
|
## [1.3.0.0](https://git.d3data.de/D3Public/oxid_twig_extensions/compare/1.2.0.0...1.3.0.0) - 2024-06-11
|
||||||
|
### Added
|
||||||
|
- isObject check
|
||||||
|
|
||||||
|
## [1.2.0.0](https://git.d3data.de/D3Public/oxid_twig_extensions/compare/1.1.0.0...1.2.0.0) - 2024-06-07
|
||||||
|
### Added
|
||||||
|
- Twig as dependency
|
||||||
|
- text, array, pcre functionality
|
||||||
|
|
||||||
|
## [1.1.0.0](https://git.d3data.de/D3Public/oxid_twig_extensions/compare/1.0.0.0...1.1.0.0) - 2024-05-07
|
||||||
|
### Added
|
||||||
|
- module settings access
|
||||||
|
- shop settings access
|
||||||
|
|
||||||
## [1.0.0.0](https://git.d3data.de/D3Public/oxid_twig_extensions/releases/tag/1.0.0.0) - 2023-01-10
|
## [1.0.0.0](https://git.d3data.de/D3Public/oxid_twig_extensions/releases/tag/1.0.0.0) - 2023-01-10
|
||||||
### Added
|
### Added
|
||||||
|
@ -11,6 +11,9 @@ services:
|
|||||||
D3\OxidTwigExtensions\ShopConfigurationExtension:
|
D3\OxidTwigExtensions\ShopConfigurationExtension:
|
||||||
tags: ['twig.extension']
|
tags: ['twig.extension']
|
||||||
|
|
||||||
|
D3\OxidTwigExtensions\IsObjectExtension:
|
||||||
|
tags: ['twig.extension']
|
||||||
|
|
||||||
# requires intl extension
|
# requires intl extension
|
||||||
# Jasny\Twig\DateExtension:
|
# Jasny\Twig\DateExtension:
|
||||||
# tags: ['twig.extension']
|
# tags: ['twig.extension']
|
||||||
|
41
src/IsObjectExtension.php
Normal file
41
src/IsObjectExtension.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* https://www.d3data.de
|
||||||
|
*
|
||||||
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||||
|
* @link https://www.oxidmodule.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace D3\OxidTwigExtensions;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
|
class isObjectExtension extends AbstractExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return TwigFunction[]
|
||||||
|
*/
|
||||||
|
public function getFunctions(): array
|
||||||
|
{
|
||||||
|
return [new TwigFunction('is_object', [$this, 'twig_method_exists'], ['is_safe' => ['html']])];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param object $entity
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function twig_method_exists($entity): bool
|
||||||
|
{
|
||||||
|
return is_object($entity);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user