SimpleInstagramFeedLibrary.php in Simple Instagram Feed Block 8.3
File
src/Services/SimpleInstagramFeedLibrary.php
View source
<?php
namespace Drupal\simple_instagram_feed\Services;
use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class SimpleInstagramFeedLibrary implements SimpleInstagramFeedLibraryInterface {
use MessengerTrait;
use StringTranslationTrait;
private $root;
public function isAvailable(bool $warning = FALSE) {
if (!file_exists($this->root . $this
->getPath())) {
if ($warning) {
$this
->messenger()
->addWarning($this
->getWarningMessage());
}
return FALSE;
}
return TRUE;
}
public function getWarningMessage() {
return $this
->t('Missing library: The <a href=":url">jquery.instagramFeed</a> library should be installed at <strong>:path</strong>.', [
':url' => 'https://github.com/jsanahuja/jquery.instagramFeed',
':path' => $this
->getPath(),
]);
}
private function getPath() {
return '/libraries/jqueryinstagramfeed/jquery.instagramFeed.min.js';
}
public function __construct($root) {
$this->root = $root;
}
public function create(ContainerInterface $container) {
return new static($container
->get('app.root'));
}
}