-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix indexing of assets #25
Conversation
Assets have a similar listing behavior as documents, hence a few more changes are necessary to get this working:
use Pimcore\Model\Asset as PimcoreAsset;
use Pimcore\Model\Asset\Listing as AssetListing;
public function getDocumentType(): ?string
{
if (!in_array($this->getType(), [DocumentInterface::TYPE_DOCUMENT, DocumentInterface::TYPE_ASSET], true)) {
return null;
}
$candidate = null;
if ($this->getType() === DocumentInterface::TYPE_DOCUMENT) {
$candidate = [
PimcoreDocument\Folder::class => 'folder',
PimcoreDocument\Page::class => 'page',
PimcoreDocument\Snippet::class => 'snippet',
PimcoreDocument\Link::class => 'link',
PimcoreDocument\Hardlink::class => 'hardlink',
PimcoreDocument\Email::class => 'email',
PimcoreDocument\Newsletter::class => 'newsletter',
PimcoreDocument\Printpage::class => 'printpage',
PimcoreDocument\Printcontainer::class => 'printcontainer',
][$this->getSubType()] ?? null;
if (!in_array($candidate, PimcoreDocument::getTypes(), true)) {
throw new UnknownPimcoreElementType($candidate);
}
}
if ($this->getType() === DocumentInterface::TYPE_ASSET) {
$candidate = [
PimcoreAsset\Archive::class => 'archive',
PimcoreAsset\Audio::class => 'audio',
PimcoreAsset\Document::class => 'document',
PimcoreAsset\Folder::class => 'folder',
PimcoreAsset\Image::class => 'image',
PimcoreAsset\Text::class => 'text',
PimcoreAsset\Unknown::class => 'unknown',
PimcoreAsset\Video::class => 'video',
][$this->getSubType()] ?? null;
if (!in_array($candidate, PimcoreAsset::getTypes(), true)) {
throw new UnknownPimcoreElementType($candidate);
}
}
if ($candidate === null) {
throw new UnknownPimcoreElementType($candidate);
}
return $candidate;
} |
FYI this is also being worked on in #40 |
@limenet Does it already work there? Does it make sense for me to continue work on that in this PR? |
That does not work for me, I need PHP 8.0 compatibility. Can you backport it and make a release? |
@limenet It seems to work, although it is quite tedious and error-prone. But it is good enough and I am happy that there is a proper solution in v2. |
This feature has been implemented in the meantime. |
There was already a
TYPE_ASSETS
constants availabe on theDocumentInterface
, but when using it errors were thrown. With these changes it should be possible to index assets as well.