Get mapping by name and branch ID.

@param string $name
Name.
@param int $branch_id
Branch ID.

@return \Drupal\openy_mappings\Entity\Mapping
Mapping entity.
551101
public function getMappingByNameAndBranch($name, $branch_id) {
    $ids = $this->queryFactory
      ->get('mapping')
      ->condition('type', self::TYPE)
      ->condition('name', $name)
      ->condition('field_branch_ct_reference', $branch_id)
      ->execute();

    if (!$ids) {
      return NULL;
    }

    $ids = reset($ids);
    return $this->storageMapping->load($ids);
  }
744230
public function getDatabaseMap($name = null)
    {
        if (null === $name) {
            $name = $this->getDefaultDatasource();
        }
        if (!isset($this->databaseMaps[$name])) {
            $class = $this->databaseMapClass;
            $this->databaseMaps[$name] = new $class($name);
        }

        return $this->databaseMaps[$name];
    }
739133
public function getSqlResultSetMapping($name)
    {
        if ( ! isset($this->sqlResultSetMappings[$name])) {
            throw MappingException::resultMappingNotFound($this->name, $name);
        }

        return $this->sqlResultSetMappings[$name];
    }
1266456
public function getProgramsByBranchAndCategory($branch_id, $category) {
    $cid = __METHOD__ . $branch_id . md5($category);
    if ($cache = $this->cache->get($cid)) {
      return $cache->data;
    }

    $params = [
      'branch' => $branch_id,
      'tag' => $category,
    ];

    $data = [];
    $result = $this->client->getSessions($params);
    foreach ($result as $item) {
      $program = new \stdClass();
      $program->id = $item->programId;
      $program->name = $item->programName;
      $data[] = $program;
    }

    $this->cache->set($cid, $data);
    return $data;
  }
209904
protected function getModuleVarFromDB($name)
    {
        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();

        $shopId = $this->getShopIdCalculator()->getShopId();
        $configKey = $this->getConfigurationKey();

        $query = "SELECT DECODE( oxvarvalue , ? ) FROM oxconfig WHERE oxvarname = ? AND oxshopid = ?";

        $value = $masterDb->getOne($query, [$configKey, $name, $shopId]);

        return unserialize($value);
    }
134893
@RequestMapping(value = "branches/{branchId}/template/instance", method = RequestMethod.GET)
    public TemplateInstance getTemplateInstance(@PathVariable ID branchId) {
        return branchTemplateService.getTemplateInstance(branchId)
                .orElseThrow(() -> new BranchNotTemplateInstanceException(branchId));
    }
1170908
public function setBranches($name, $branch, $add = false)
    {
        $this->arguments[] = 'set-branches';
        if ($add) {
            $this->arguments[] = '--add';
        }
        $this->arguments[] = $name;
        $this->arguments[] = $branch;
        return $this;
    }
352548
public function findBranchByNodeId(Branch $tree, $nodeId)
    {
        foreach ($tree->getChildren() as $branch) {
            if ($branch->getNodeId() == $nodeId) {
                return $branch;
            }

            // recursive search:
            $branch = $this->findBranchByNodeId($branch, $nodeId);
            if ($branch) {
                return $branch;
            }
        }

        return null;
    }
525883
protected function hasGitBranch($branch_name)
    {
        $task = $this->getGitBuildStack()
            ->exec("rev-parse -q --verify {$branch_name}");

        $result = $this->runSilentCommand($task);

        return !empty($result->getMessage());
    }
812717
public function getBranchByDaxkoBranchId($id) {
    $cache = &drupal_static(__FUNCTION__);

    if (!isset($cache[$id])) {
      $ids = $this->queryFactory
        ->get('mapping')
        ->condition('type', 'branch')
        ->condition('field_daxko_branch_id', $id)
        ->execute();

      if (!$ids) {
        return NULL;
      }

      // Get mapping.
      $mapping_storage = $this->entityTypeManager->getStorage('mapping');
      $mapping = $mapping_storage->load(reset($ids));

      // Get node.
      $node_id = $mapping->field_ref_branch_id->target_id;
      $node_storage = $this->entityTypeManager->getStorage('node');
      $cache[$id] = $node_storage->load($node_id);
    }

    return $cache[$id];
  }
1184112
protected function _joinPath($dir, $name) {
		$sql = 'SELECT id FROM '.$this->tbf.' WHERE parent_id="'.$dir.'" AND name="'.$this->db->real_escape_string($name).'"';

		if (($res = $this->query($sql)) && ($r = $res->fetch_assoc())) {
			$this->updateCache($r['id'], $this->_stat($r['id']));
			return $r['id'];
		}
		return -1;
	}
881719
public function morphTo( $name = null, $type = null, $id = null )
	{
		// If no name is provided, we will use the backtrace to get the function name
		// since that is most likely the name of the polymorphic interface. We can
		// use that to get both the class and foreign key that will be utilized.
		if ( is_null( $name ) )
		{
			list( $current, $caller ) = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2 );

			$name = Str::snake( $caller['function'] );
		}

		list( $type, $id ) = $this->getMorphs( $name, $type, $id );

		// If the type value is null it is probably safe to assume we're eager loading
		// the relationship. In this case we'll just pass in a dummy query where we
		// need to remove any eager loads that may already be defined on a model.
		if ( empty( $class = $this->$type ) )
		{
			return new MorphTo( $this->newQuery()->setEagerLoads( [] ), $this, $id, null, $type, $name );
		}

		// If we are not eager loading the relationship we will essentially treat this
		// as a belongs-to style relationship since morph-to extends that class and
		// we will pass in the appropriate values so that it behaves as expected.
		else
		{
			$class = $this->getActualClassNameForMorph( $class );

			$instance = new $class;

			return new MorphTo( $instance->newQuery(), $this, $id, $instance->getKeyName(), $type, $name );
		}
	}
384638
@RequestMapping(value = "branches/{branchId}/copy", method = RequestMethod.GET)
    public Form copy(@PathVariable ID branchId) {
        return Form.create()
                .with(
                        Selection.of("sourceBranch")
                                .label("Source branch")
                                .help("Branch to copy configuration from")
                                // All branches for all projects
                                .items(structureService.getProjectList().stream()
                                        .flatMap(project -> structureService.getBranchesForProject(project.getId()).stream())
                                        // Keeps only the different branches
                                        .filter(branch -> !branchId.equals(branch.getId()))
                                        .collect(Collectors.toList()))
                )
                .with(
                        Replacements.of("replacements")
                                .label("Replacements")
                )
                ;
    }
796805
public static function get($name, $for_id = null)
    {

        // Pickup the value from the cache if we can. Otherwise,
        // read the value for the database and cache it for next
        // time.
        return Cache::rememberForever(self::get_key_prefix($name,
            self::get_affected_id($for_id)), function () use ($name, $for_id) {

            // Init a new MODEL
            $value = (new static::$model);

            // If we are not in the global scope, add a constraint
            // to be user group specific.
            if (static::$scope != 'global')
                $value = $value->where('group_id', self::get_affected_id($for_id));

            // Retrieve the value
            $value = $value->where('name', $name)
                ->value('value');

            if ($value)
                return json_decode($value);

            // If we have no value, check if we can return
            // a default setting
            if (array_key_exists($name, static::$defaults))
                return static::$defaults[$name];

            return null;
        });
    }
1053801
public function getBranchByInternalName($internalName, $lang = null)
    {
        $this->initNodeVersions();

        $lang = $lang ?: $this->currentLocale->getCurrentLocale();

        $matches = function (Branch $branch) use ($internalName, $lang) {
            return $internalName === $branch->getInternalName() && $lang === $branch->getLang();
        };

        return array_reduce($this->branches, function (Branch $result = null, Branch $branch) use ($matches) {
            return $matches($branch) ? $branch : $result;
        });
    }
539407
def find(cls, name):
        ''''''
        if not cls.mapping:  # pragma: no branch
            for _, obj in inspect.getmembers(exceptions):
                if inspect.isclass(obj):
                    if issubclass(obj, exceptions.NSQException):  # pragma: no branch
                        if hasattr(obj, 'name'):
                            cls.mapping[obj.name] = obj
        klass = cls.mapping.get(name)
        if klass == None:
            raise TypeError('No matching exception for %s' % name)
        return klass
314873
public function setHead($name, $branch)
    {
        $this->arguments[] = 'set-head';
        $this->arguments[] = $name;
        $this->arguments[] = $branch;
        return $this;
    }