Dağıtım Ağı

  • Tarih : 19.01.2020 11:54
  • Son Güncelleme : 21.05.2025 16:08

Nesne Sabitleri

Name Info Type Visibility
$styles Stil dosyalarını tutar. Array Static
$scripts Script dosyalarını tutar. Array Static

Nesne Özellikleri (Metotlar)

Dağıtım ağı nesnesi toplam 4 adet metota sahiptir. Tüm metotlar static olarak tanımlanmıştır.

  1. script
  2. style
  3. styles
  4. scripts

 

1. script

Dağıtım ağından bir script dosyası çağırmaya yarayan metottur. Geriye String veri döndürür. String veri tipinde tek bir parametre alır. Dağıtım ağının sahip olduğu script dosyaları aşağıda listelenmiştir.

$scripts = [
    'jquery'       =>  PUBLIC_URI.'js/jquery.min.js',
    'angular'      => 'https://ajax.googleapis.com/ajax/libs/angularjs/1.7.5/angular.min.js',
    'react'        => 'https://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react.min.js',
    'bootstrap'    =>  PUBLIC_URI.'bootstrap/js/bootstrap.min.js',
    'morris'       => 'https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js',
    'sweetalert'   =>  PUBLIC_URI.'js/sweetalert.min.js',
    'html5shiv'    =>  PUBLIC_URI.'js/html5shiv.js',
    'lightbox'     =>  PUBLIC_URI.'js/lightbox.min.js',
    'popper'       =>  PUBLIC_URI.'js/popper.min.js',
    'prism'        =>  PUBLIC_URI.'js/prism.js'
];

Bu metodu kullanarak bir script dosyası çağırmak için örnek kod:

echo CDN::script("angular");
// Çıktı: https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js

Görünüm katmanlarından bu metodu kullanmak için Twig Tema sistemine harici fonksiyonlar eklenerek bu özellik kazandırılmıştır. Örnek kod:

<script src="{ { CDNScripts.angular } }"></script>

 

2. style

Dağıtım ağından bir stil dosyası çağırmaya yarayan metottur. Geriye String veri döndürür. String veri tipinde tek bir parametre alır. Dağıtım ağının sahip olduğu stil dosyaları aşağıda listelenmiştir.

$styles = [
    'fontawesome'  =>  PUBLIC_URI.'fontawesome/css/all.min.css',
    'bootstrap'    =>  PUBLIC_URI.'bootstrap/css/bootstrap.min.css',
    'morris'       => 'https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css',
    'datepicker'   => 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css',
    'morris'       => 'https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css',
    'lightbox'     =>  PUBLIC_URI.'css/lightbox.min.css',
    'prism'        =>  PUBLIC_URI.'css/prism.css'
];

Bu metodu kullanarak bir stil dosyası çağırmak için örnek kod:

echo CDN::style("morris");
// Çıktı: https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css

Görünüm katmanlarından bu metodu kullanmak için Twig Tema sistemine harici fonksiyonlar eklenerek bu özellik kazandırılmıştır. Örnek kod:

<link rel="stylesheet" src="{ { CDNStyles.morris } }" />

 

3. styles

Dağıtım ağında bulunan tüm stilleri almaya yarayan metottur. Geriye Array veri döndürür.

Örnek kod:

print_r(CDN::styles());

 

4. scripts

Dağıtım ağında bulunan tüm scriptleri almaya yarayan metottur. Geriye Array veri döndürür.

Örnek kod:

print_r(CDN::scripts());