Collect ids from field of item

@param $item
@param string $field
@return array
762759
protected function collectIdsFromField($item, $field)
    {
        $ids = Arr::get($item, $field, []);

        return is_object($ids) && method_exists($ids, 'toArray') ? $ids->toArray() : (array) $ids;
    }
1053971
public function values($field)
    {
        $values = [];
        foreach ($this->distinct()->select([$field])->all() as $v) {
            $values[] = $v[$field];
        }

        return $values;
    }
229966
public function getPluginsThatCanFillItem(Item $item, $field)
    {
        $plugins = [];
        /* @var $plugin Refiller */
        foreach ($this->plugins as $plugin) {
            if ($plugin->isCanRefill($item, $field) || $plugin->isCanSearch($item, $field)) {
                $plugins[] = $plugin;
            }
        }

        return $plugins;
    }
912750
private function getFields($field)
    {
        if ($field instanceof Group || $field instanceof Fieldset) {
            $elements = $field->getFields();
        } elseif ($field instanceof AbstractField) {
            $elements = [$field];
        } else {
            throw new \InvalidArgumentException(sprintf(
                "Invalid type '%s'",
                is_object($field) ? get_class($field) : gettype($field)
            ));
        }

        return $elements;
    }
1338913
private function show_single_field( $items, $field ) {
		$key    = null;
		$values = array();

		foreach ( $items as $item ) {
			$item = (object) $item;

			if ( null === $key ) {
				$key = $this->find_item_key( $item, $field );
			}

			if ( 'json' === $this->args['format'] ) {
				$values[] = $item->$key;
			} else {
				\WP_CLI::print_value(
					$item->$key,
					array(
						'format' => $this->args['format'],
					)
				);
			}
		}

		if ( 'json' === $this->args['format'] ) {
			echo json_encode( $values );
		}
	}
218986
public static function getFieldValue($item,$field,$objectFieldAccess=false)
    {
        if(is_array($item) && array_key_exists($field, $item)){
            return $item[$field];
        }else if(is_object($item)){
            return ObjectUtil::getPropertyValue($item, $field,$objectFieldAccess);
        }
        return null;
    }
108561
protected function getItemLineTaxRuleGroupId(array $item)
    {
        if (isset($item['id_tax_rules_group'])) {
            return (int) $item['id_tax_rules_group'];
        } elseif (isset($item['id_tax'])) {
            $query = 'select distinct id_tax_rules_group from ps_tax_rule where id_tax = ' . (int) $item['id_tax'];
            $results = Db::getInstance()->executeS($query);
            return count($results) === 1 ? (int) $results[0]['id_tax_rules_group'] : 0;
        }
        return 0;
    }
670781
public function refillFromSearchResult(Item $item, $field, array $data)
    {
        if (!empty($data['url'])) {
            $item->addSource((new Source())->setUrl($data['url']));
            $item = $this->refill($item, $field);
        }

        return $item;
    }
824512
private function get_list_or_item($data, $field, $i = null, $default = '')
    {
        $i = ($i === false || count($this->article_ids) > 1 ) ? $i : 0;

        if ($i === null || $i === false) {
            $result = [];
            foreach ($data as $page_id => $item) {
                $result[$page_id] = isset($item[$field]) ? $item[$field] : $default;
            }
            return $result;
        }

        return isset($data[$this->article_ids[$i]][$field]) ? $data[$this->article_ids[$i]][$field] : $default;
    }
1239738
public function parse(array $item): array
    {
        $siteSettings = [];
        foreach ($item['siteSettings'] as $settingKey => $settings) {
            $siteId = isset($settings['siteId']) ? Craft::$app->sites->getSiteByHandle($settings['siteId'])->id : Craft::$app->sites->getPrimarySite()->id;
            unset($settings['siteId']);
            $siteSettings[$siteId] = new CategoryGroup_SiteSettings(array_merge($settings, [
                'siteId' => $siteId,
                'hasUrls' => !empty($settings['uriFormat']),
            ]));
        }
        $categoryGroup = new CategoryGroup([
            'name' => $item['name'],
            'handle' => $item['handle'],
            'maxLevels' => $item['maxLevels'],
        ]);

        $categoryGroup->setSiteSettings($siteSettings);

        return [$categoryGroup, null];
    }
1060956
private function _pop(& $item) : array
    {
        $values = $this->getValues();
        if (empty($values)) {
            $item = null;
            return $values;
        }
        $item = array_pop($values);
        return $values;
    }
857071
public function parse(array $item, bool $subField = false): array
    {
        $groupId = false;
        if ($subField === false) {
            // Attempt to find and set group id.
            if (isset($item['group'])) {
                $groupId = $this->getGroupIdByName($item['group']);
                if ($groupId) {
                    unset($item['group']);
                }
            } else {
                $errors = [
                    'type' => [
                        Architect::t('Field group is missing.')
                    ]
                ];
                return [null, $errors];
            }
        }

        // Attempt to find matching field type.
        $matchingFieldTypes = $this->getMatchingFieldTypes($item['type']);
        if (\count($matchingFieldTypes) === 1) {
            $item = array_merge($item, [
                'type' => array_pop($matchingFieldTypes)
            ]);
        } else if (\count($matchingFieldTypes) <= 0) {
            $errors = [
                'type' => [
                    Architect::t('No field type matching "{fieldType}".', ['fieldType' => $item['type']])
                ]
            ];
            return [null, $errors];
        } else {
            $errors = [
                'type' => [
                    Architect::t('Too many field types matching "{fieldType}"', ['fieldType' => $item['type']]) . '<br>' . Architect::t('Possible values:') . '<br>' . implode('<br>', $matchingFieldTypes)
                ]
            ];
            return [null, $errors];
        }
        if ($subField === false) {
            $this->convertOld($item);
        }
        try {
            $this->mapSources($item);
        } catch (\Exception $e) {
            $errors = [
                'source' => [
                    Architect::t('There was an error mapping the source handles to existing sources.')
                ]
            ];
            return [null, $errors];
        }
        if ($item['type'] === Matrix::class || $item['type'] === SuperTableField::class || $item['type'] === Neo::class) {
            $this->mapTypeSettings($item);
            if ($subField) {
                $blockTypes = &$item['typesettings']['blockTypes'];
            } else {
                $blockTypes = &$item['blockTypes'];
            }
        }
        if ($item['type'] === Matrix::class) {
            if (isset($blockTypes[0])) {
                $this->convertBlockTypesToNew($blockTypes);
            }
            foreach ($blockTypes as $blockKey => &$blockType) {
                foreach ($blockType['fields'] as $fieldKey => $field) {
                    list ($field, $errors) = $this->parse($field, true);
                    if ($field === null) {
                        return [$field, $errors];
                    }
                    $blockType['fields'][$fieldKey] = $field;
                }
            }
            unset($blockType);
        } else if ($item['type'] === Neo::class) {
            if (isset($blockTypes[0])) {
                $this->convertBlockTypesToNew($blockTypes);
            }
            foreach ($blockTypes as &$blockType) {
                if (!array_key_exists('childBlocks', $blockType)) {
                    $blockType['childBlocks'] = null;
                }
                foreach ($blockType['fieldLayout'] as &$fields) {
                    if (is_array($fields)) {
                        $fields = $this->handlesToIds($fields);
                    }
                }
                unset($fields);
                if (\is_array($blockType['requiredFields'])) {
                    $blockType['requiredFields'] = $this->handlesToIds($blockType['requiredFields']);
                }
                unset($requiredFields);
            }
            unset($blockType);
        } else if ($item['type'] === SuperTableField::class) {
            if (!isset(array_values($blockTypes)[0]['fields'])) {
                $newBlockTypes = [
                    [
                        'fields' => $blockTypes
                    ]
                ];
                $blockTypes = $newBlockTypes;
                $this->convertBlockTypesToNew($blockTypes);
            }
            foreach ($blockTypes as $blockKey => &$blockType) {
                foreach ($blockType['fields'] as $fieldKey => &$field) {
                    $this->mapSources($field);
                    if ($field['type'] === Matrix::class) {
                        $this->convertBlockTypesToNew($field['typesettings']['blockTypes']);
                    }
                }
                unset($field);
            }
            unset($blockType);
        }

        if ($groupId && Craft::$app->fields->getGroupById((int) $groupId)) {
            $fieldObject = array_merge($item, [
                'groupId' => $groupId
            ]);

            if ($item['type'] === Neo::class) {
                $fieldObject['settings'] = [
                    'blockTypes' => $fieldObject['blockTypes']
                ];
                unset($fieldObject['blockTypes']);
            }

            $field = Craft::$app->fields->createField($fieldObject);

            return [$field, $field->getErrors()];
        }
        if ($subField) {
            return [$item, null];
        }
        $errors = [
            'group' => [
                Architect::t('No field group matching "{groupName}".', ['groupName' => $item['group']])
            ]
        ];
        return [null, $errors];
    }
254979
protected function getFieldItems(Field $field)
    {
        if ($field->hasForeignRelation() && $field->isOnFormView) {
            return sprintf('$%s', $field->getForeignRelation()->getCollectionName());
        }
        $labels = $field->getOptionsByLang();
        return sprintf('[%s]', implode(',' . PHP_EOL, $this->getKeyValueStringsFromLabels($labels)));
    }
526683
public function id($items = array())
    {
        if (is_array($items) && !empty($items)) {
            foreach ($items as $key => $value) {
                $args[] = $this->escape($key, true);
                $args[] = $this->escape($value, true);
            }
        }

        list($code, $response) = $this->execute('ID',
            array(!empty($args) ? '(' . implode(' ', (array) $args) . ')' : $this->escape(null)),
            0, '/^\* ID /i');

        if ($code == self::ERROR_OK && $response) {
            $response = substr($response, 5); // remove prefix "* ID "
            $items    = $this->tokenizeResponse($response, 1);
            $result   = null;

            for ($i=0, $len=count($items); $i<$len; $i += 2) {
                $result[$items[$i]] = $items[$i+1];
            }

            return $result;
        }

        return false;
    }
868459
public function fetchAllOf(string $field): array
    {
        $array = [];
        foreach ($this->fetchAllGenerator() as $record) {
            $array[] = $record[$field] ?? null;
        }

        return $array;
    }
56026
private function getTags($item)
    {
        if ($item instanceof PoolInterface) {
            return $this->getPoolTags($item);
        }
        return $this->getRunTags($item);
    }
1121470
public static function filterFieldListByTag($fieldsList, $itemType, $itemProp)
    {
        $result = array();
        $tag = md5($itemProp.IDSPLIT.$itemType);

        foreach ($fieldsList as $field) {
            if ($field->tag !== $tag) {
                continue;
            }
            if (($field->itemtype !== $itemType) || ($field->itemprop !== $itemProp)) {
                continue;
            }
            $result[] = $field;
        }

        return $result;
    }