Skip to content

Instantly share code, notes, and snippets.

View mficzel's full-sized avatar

Martin Ficzel mficzel

  • sitegeist neos solutions GmbH
  • Germany, Hamburg
View GitHub Profile
@mficzel
mficzel / Vendor\Site\Command\ResourceCommandController.php
Last active January 9, 2023 17:12
Resource publishing with limits ... to avoid memory errors
<?php
namespace Vendor\Site\Command;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Neos\Flow\ResourceManagement\CollectionInterface;
use Neos\Flow\ResourceManagement\PersistentResource;
use Neos\Flow\ResourceManagement\ResourceManager;
use Neos\Flow\ResourceManagement\ResourceRepository;
@mficzel
mficzel / RemoveNodesWithHiddenParentsFromSearchResults.php
Last active April 4, 2023 10:27
Remove items from search result that are not connected to root because of hidden parents
<?php
namespace Vendor\Site\Aspects;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Aop\JoinPointInterface;
/**
* @Flow\Aspect
*/
@mficzel
mficzel / Test.fusion
Created July 15, 2022 17:21
Switch between renderers based on the aspect ratio of a Kaleidoscope image
prototype(Vendor.Site:TestImageFormatSwitch) < prototype(Neos.Fusion:Component) {
@styleguide {
title = "Test Image Format Switch"
props {
imageSource = Sitegeist.Kaleidoscope:DummyImageSource
}
useCases {
square {
@mficzel
mficzel / gist:da4b29cf11dc0e60881133fa4510f37d
Last active July 13, 2022 11:19
Use Symfony console helper for selection with autocomplete
# @see https://symfony.com/doc/current/components/console/helpers/questionhelper.html
$bundles = ['AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle'];
$question = new Question('Please enter the name of a bundle: ', 'FooBundle');
$question->setAutocompleterValues($bundles);
$input = new SymfonyStringInput('');
$output = new SymfonyConsoleOutput();
$helper = new QuestionHelper();
@mficzel
mficzel / NodeTypes.Content.override.yaml
Last active June 23, 2022 12:09
Restore Prototype generators when updating old neos projects with fluid rendering
'Neos.Neos:Content':
options:
fusion:
prototypeGenerator: Neos\Neos\Domain\Service\DefaultContentPrototypeGenerator
@mficzel
mficzel / ThemedComponent.fusion
Created February 22, 2022 18:14
Themed Component
prototype(Vendow.Site:ThemedComponent) < prototype(Neos.Fusion:Component) {
name = null
theme = 'Theme1'
# all props
renderer = Neos.Fusion:Renderer {
type = ${props.theme + ':' + props.name}
@mficzel
mficzel / CommandController.php
Created March 3, 2021 14:41
Partial Node export
<?php
namespace Sitegeist\NodeShippingService\Command;
use Neos\ContentRepository\Domain\Service\ImportExport\NodeExportService;
use Neos\ContentRepository\Domain\Service\ImportExport\NodeImportService;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Neos\Neos\Exception as NeosException;
use Neos\Utility\Files;
use Neos\ContentRepository\Domain\Repository\NodeDataRepository;
@mficzel
mficzel / _helpers.tpl
Last active January 19, 2021 20:15
Kubernetes Green / Blue deployment with Helm
{{/*
Create revion color "green" / "blue" from release number
*/}}
{{- define "project.revisioncolor" -}}
{{- if mod .Release.Revision 2 -}}
{{- printf "green" -}}
{{- else -}}
{{- printf "blue" -}}
{{- end -}}
{{- end -}}
@mficzel
mficzel / example.fusion
Last active September 18, 2020 12:27
Filter lists with Neos.Fusion:Reduce
foo = Neos.Fosion:Reduce {
items = ${something}
initialValue = ${[]}
# when the condition matches include the item into the result
# otherwise return sam array as before
itemReducer = ${ (__condition__) ? Array.push(carry, item) : carry}
#defaults
itemName = 'item'
@mficzel
mficzel / Overview.md
Last active September 4, 2020 08:16
Neos Caching 101

Caching is hard but worth the hassle

Motivation

  • no clear cache button
  • 100 % transparent for editors
  • good caching makes sites fast

We are forced to configure caching right as otherwise editors will complain