You are here

public function TinyPng::setApiKey in TinyPNG 8

Set TinyPNG API key.

Parameters

string $key: TinyPNG API key.

bool $reset: Force to update previous API key.

Return value

$this Current instance.

Overrides TinyPngInterface::setApiKey

2 calls to TinyPng::setApiKey()
TinyPng::setFromFile in src/TinyPng.php
Compress with \Tinify\fromFile.
TinyPng::setFromUrl in src/TinyPng.php
Compress with \Tinify\fromUrl.

File

src/TinyPng.php, line 87

Class

TinyPng
Class TinyPng.

Namespace

Drupal\tinypng

Code

public function setApiKey($key = NULL, $reset = FALSE) {
  if (empty($this->apiKey) || $reset) {
    if (empty($key)) {
      $key = $this->config
        ->get('api_key');
    }
    $this->apiKey = $key;
    TinifySetKey($key);
    TinifySetAppIdentifier('Drupal/' . \Drupal::VERSION);
  }
  return $this;
}