수업 시간에이 문제를 발견했습니다 Magento\Framework\View\Layout\ScheduledStructure\Helper
기능이 있습니다 _generateAnonymousName
:
protected function _generateAnonymousName($class)
{
$position = strpos($class, '\\Block\\');
$key = $position !== false ? substr($class, $position + 7) : $class;
$key = strtolower(trim($key, '_'));
return $key . $this->counter++;
}
scheduleStructure
함수 에서 호출 합니다.
public function scheduleStructure(
Layout\ScheduledStructure $scheduledStructure,
Layout\Element $currentNode,
Layout\Element $parentNode
) {
// if it hasn't a name it must be generated
if (!(string)$currentNode->getAttribute('name')) {
$name = $this->_generateAnonymousName($parentNode->getElementName() . '_schedule_block'); // CALL HERE
$currentNode->setAttribute('name', $name);
}
$path = $name = (string)$currentNode->getAttribute('name');
// Prepare scheduled element with default parameters [type, alias, parentName, siblingName, isAfter]
$row = [
self::SCHEDULED_STRUCTURE_INDEX_TYPE => $currentNode->getName(),
self::SCHEDULED_STRUCTURE_INDEX_ALIAS => '',
self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME => '',
self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME => null,
self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER => true,
];
$parentName = $parentNode->getElementName();
//if this element has a parent element, there must be reset [alias, parentName, siblingName, isAfter]
if ($parentName) {
$row[self::SCHEDULED_STRUCTURE_INDEX_ALIAS] = (string)$currentNode->getAttribute('as');
$row[self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME] = $parentName;
list($row[self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME],
$row[self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER]) = $this->_beforeAfterToSibling($currentNode);
// materialized path for referencing nodes in the plain array of _scheduledStructure
if ($scheduledStructure->hasPath($parentName)) {
$path = $scheduledStructure->getPath($parentName) . '/' . $path;
}
}
$this->_overrideElementWorkaround($scheduledStructure, $name, $path);
$scheduledStructure->setPathElement($name, $path);
$scheduledStructure->setStructureElement($name, $row);
return $name;
}
이 경우 차단 이름은 다음과 같습니다.
before.body.end_schedule_block1
before.body.end_schedule_block2
- ...
컨테이너에 이름이없는 총 블록을 정의해야하며 주문 블록 이름은 컨테이너에서 제거해야한다고 생각합니다.
[Vendor_Module]::template.phtml