/** * Returns whether this is the first time the element's content has been edited. * * @return bool */ protected function isFresh() { // If this is for a Matrix block, we're more interested in its owner if (isset($this->element) && $this->element->getElementType() == ElementType::MatrixBlock) { $element = $this->element->getOwner(); } else { $element = $this->element; } return !$element || empty($element->getContent()->id) && !$element->hasErrors(); }