小编RW2*_*W24的帖子

Laravel:命令中的依赖注入

是否可能对自定义类进行依赖注入command

我正在尝试这个:

<?php

namespace vendor\package\Commands;

use Illuminate\Console\Command;
use vendor\package\Models\Log;
use vendor\package\Updates\UpdateStatistics;

class UpdatePublishmentStats extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'vendorname:updatePublishmentStats';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Updates Twitter followers & Facebook page likes';

    /**
     * Contact implementation
     * @var vendor\package\Update\UpdateStatistics
     */
    protected $stats;

    /**
     * Create a new command instance.
     *
     * @return …
Run Code Online (Sandbox Code Playgroud)

php dependency-injection laravel laravel-5

6
推荐指数
2
解决办法
6554
查看次数

Youtube iFrame API'YT未定义'

我正在尝试将此代码放在模块函数中:

$(document).ready(function()
    {
        VIDEO.onYouTubeIframeAPIReady();
}


        var VIDEO = (function (my, $){
var tag = document.createElement('script');
var onPlayerStateChange;
  tag.src = "https://www.youtube.com/iframe_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;


   my.onYouTubeIframeAPIReady =function() {
    player = new YT.Player('player', {
      height: '490',
      width: '880',
      videoId: SONG.getArtistId(),
      playerVars: { controls:1, showinfo: 0, rel: 0, showsearch: 0, iv_load_policy: 3 },
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange,
        'onError': catchError
      }
    });
  }

  function onPlayerReady(event) {


  if(typeof(SONG.getArtistId()) == undefined)
  {
    console.log("undefineeeed"); 
  } 


    event.target.playVideo();   
  }

  var done = false; …
Run Code Online (Sandbox Code Playgroud)

javascript iframe module youtube-api youtube-javascript-api

0
推荐指数
1
解决办法
1万
查看次数