Commit fe9c81e1 authored by gbyte.co's avatar gbyte.co

Clean up some

parent 7066cd20
......@@ -41,7 +41,7 @@ services:
public: false
simple_sitemap.entity_url_generator:
class: Drupal\simple_sitemap\Batch\EntityUrlGenerator
class: Drupal\simple_sitemap\Batch\Generator\EntityUrlGenerator
public: true
arguments:
- '@simple_sitemap.generator'
......@@ -53,7 +53,7 @@ services:
- '@simple_sitemap.entity_helper'
simple_sitemap.custom_url_generator:
class: Drupal\simple_sitemap\Batch\CustomUrlGenerator
class: Drupal\simple_sitemap\Batch\Generator\CustomUrlGenerator
public: true
arguments:
- '@simple_sitemap.generator'
......@@ -65,7 +65,7 @@ services:
- '@simple_sitemap.entity_helper'
simple_sitemap.arbitrary_url_generator:
class: Drupal\simple_sitemap\Batch\ArbitraryUrlGenerator
class: Drupal\simple_sitemap\Batch\Generator\ArbitraryUrlGenerator
public: true
arguments:
- '@simple_sitemap.generator'
......
......@@ -115,16 +115,6 @@ class Batch {
];
}
/**
* Batch callback function which generates urls to entity paths.
*
* @param array $entity_info
* @param array $batch_info
* @param array &$context
*
* @see https://api.drupal.org/api/drupal/core!includes!form.inc/group/batch/8
*/
/**
* Batch callback function which generates URLs.
*
......
<?php
namespace Drupal\simple_sitemap\Batch;
namespace Drupal\simple_sitemap\Batch\Generator;
/**
* Class ArbitraryUrlGenerator
* @package Drupal\simple_sitemap\Batch
* @package Drupal\simple_sitemap\Batch\Generator
*/
class ArbitraryUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface {
......@@ -16,8 +16,7 @@ class ArbitraryUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInte
* @see \hook_simple_sitemap_arbitrary_links_alter()
*/
public function generate($arbitrary_paths) {
foreach ($this->getBatchIterationElements($arbitrary_paths) as $i => $path_data) {
foreach ($this->getBatchIterationElements(array_values($arbitrary_paths)) as $i => $path_data) {
$this->setCurrentId($i);
$this->addUrl($path_data);
}
......
<?php
namespace Drupal\simple_sitemap\Batch;
namespace Drupal\simple_sitemap\Batch\Generator;
use Drupal\Core\Url;
/**
* Class BatchUrlGenerator
* @package Drupal\simple_sitemap\Batch
* Class CustomUrlGenerator
* @package Drupal\simple_sitemap\Batch\Generator
*
* @todo Add image support
*/
class CustomUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface {
......
<?php
namespace Drupal\simple_sitemap\Batch;
namespace Drupal\simple_sitemap\Batch\Generator;
/**
* Class BatchUrlGenerator
* @package Drupal\simple_sitemap\Batch
* Class EntityUrlGenerator
* @package Drupal\simple_sitemap\Batch\Generator
*/
class EntityUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterface {
......@@ -73,19 +73,6 @@ class EntityUrlGenerator extends UrlGeneratorBase implements UrlGeneratorInterfa
$this->processSegment();
}
/**
* @param $entity_type_name
* @param $entity_id
* @return array
*/
protected function getImages($entity_type_name, $entity_id) {
$images = [];
foreach ($this->entityHelper->getEntityImageUrls($entity_type_name, $entity_id) as $Url) {
$images[]['path'] = $Url;
}
return $images;
}
/**
* @param array $entity_info
* @return \Drupal\Core\Entity\EntityInterface[]
......
<?php
namespace Drupal\simple_sitemap\Batch;
namespace Drupal\simple_sitemap\Batch\Generator;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\ContentEntityBase;
......@@ -16,8 +16,8 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Path\PathValidator;
/**
* Class BatchUrlGenerator
* @package Drupal\simple_sitemap\Batch
* Class UrlGeneratorBase
* @package Drupal\simple_sitemap\Batch\Generator
*/
class UrlGeneratorBase {
......@@ -303,7 +303,6 @@ class UrlGeneratorBase {
* @return array
*/
protected function getBatchIterationElements(array $elements) {
if ($this->needsInitialization()) {
$this->initializeBatch(count($elements));
}
......@@ -314,4 +313,17 @@ class UrlGeneratorBase {
return $elements;
}
/**
* @param $entity_type_name
* @param $entity_id
* @return array
*/
protected function getImages($entity_type_name, $entity_id) {
$images = [];
foreach ($this->entityHelper->getEntityImageUrls($entity_type_name, $entity_id) as $Url) {
$images[]['path'] = $Url;
}
return $images;
}
}
<?php
namespace Drupal\simple_sitemap\Batch;
namespace Drupal\simple_sitemap\Batch\Generator;
/**
* Interface UrlGeneratorInterface
* @package Drupal\simple_sitemap\Batch
* @package Drupal\simple_sitemap\Batch\Generator
*/
interface UrlGeneratorInterface {
......
......@@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface;
/**
* Class SimplesitemapCustomLinksForm
* @package Drupal\simple_sitemap\Form
*
* @todo Add image support
*/
class SimplesitemapCustomLinksForm extends SimplesitemapFormBase {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment