【发布时间】:2020-09-21 12:29:15
【问题描述】:
我目前正在尝试按有效时间对我可以获得的所有 Childobjects 进行排序。
我当前的代码没有对任何东西进行排序:
$children = $this->productRepository->findByParent($product->getNumber());
foreach ($children as $child) {
//debug::debug($child->getvalidityPeriod());
$product->addChild($child);
}
正如在调试中已经看到的那样,$child->getvalidityPeriod() 可以将所需的信息作为整数获取。我想,一定有办法通过它们的validityPeriod对这个对象数组进行排序,但是我该如何管理呢?我需要创建一个新方法并在那里过滤它还是我可以在 ForEach 循环之前使用一些东西?
伪类:
$children = $this->productRepository->findByParent($product->getNumber());
ObjectSortFunction($children, 'getvalidityPeriod');
...and then for each...
如果有人能帮助我,那就太棒了!
【问题讨论】:
标签: typo3 extbase typo3-extensions