Skip to content

Instantly share code, notes, and snippets.

View juancasantito's full-sized avatar

Juancasantito juancasantito

  • MTechLLC
  • Leon,Nicaragua
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>homework1</title>
</head>
<body>
profiles:juanca* master$ drush cim sync -y
Collection Config Operation
system.menu.account create
block.block.bartik_branding create
block.block.bartik_breadcrumbs create
block.block.bartik_content create
system.menu.footer create
block.block.bartik_local_actions create
block.block.bartik_local_tasks create
system.menu.main create
class GmapJSONReader extends JSONReader {
public function getSourceFields($url) {
$items = parent::getSourceFields($url);
// Loop over the JSON values, walk the tree and extract as keyed values.
foreach ($items as &$item) {
if (isset($item['address_components']) && is_array($item['address_components'])) {
foreach ($item['address_components'] as $component) {
if (isset($component['long_name']) && isset($component['types']) && is_array($component['types'])) {
foreach ($component['types'] as $type) {
$item[$type] = $component['long_name'];
$url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452';
$client = new \GuzzleHttp\Client;
$response = $client->get($url, [
'headers' => ['Accept' => application/json],
])->getBody();
$array = json_decode($response, TRUE);
$iterator = new \RecursiveIteratorIterator(
new \RecursiveArrayIterator($array),
\RecursiveIteratorIterator::SELF_FIRST);
// Recurse through the result array. When there is an array of items at the