PHP 8.2.31
Preview: SafeToOneAssociationLoadTrait.php Size: 1011 B
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Doctrine/EntityTraits/SafeToOneAssociationLoadTrait.php

<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing

namespace MailPoet\Doctrine\EntityTraits;

if (!defined('ABSPATH')) exit;


use MailPoetVendor\Doctrine\ORM\EntityNotFoundException;
use MailPoetVendor\Doctrine\ORM\Proxy\Proxy;

trait SafeToOneAssociationLoadTrait {
  private function safelyLoadToOneAssociation(string $propertyName, $emptyValue = null) {
    if (!property_exists($this, $propertyName)) {
      throw new \InvalidArgumentException("Property '$propertyName' does not exist on class '" . get_class($this) . "'");
    }

    if (!$this->$propertyName instanceof Proxy) {
      return;
    }

    if ($this->$propertyName->__isInitialized()) {
      return;
    }

    // if a proxy exists (= we have related entity ID), try to load it
    // to see if it is a valid ID referencing an existing entity
    try {
      $this->$propertyName->__load();
    } catch (EntityNotFoundException $e) {
      $this->$propertyName = $emptyValue;
    }
  }
}

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
543 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
590 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
636 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
0 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1011 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
579 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).